Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Calendar with day-of-year

Aug
2,832
149
The main calendar I use is the QCAL command from the ISO8601 plugin.

Sometimes, though,
I need a calendar that shows the day of the year.

I have Cygwin installed on my system,
which has the CAL.EXE command.

Code:
E:\Utils>cal --help

Usage:
 cal [options] [[[day] month] year]
 cal [options] <timestamp|monthname>

Display a calendar, or some part of it.
Without any arguments, display the current month.

Options:
 -1, --one             show only a single month (default)
 -3, --three           show three months spanning the date
 -n, --months <num>    show num months starting with date's month
 -S, --span            span the date when displaying multiple months
 -s, --sunday          Sunday as first day of week
 -m, --monday          Monday as first day of week
 -j, --julian          use day-of-year for all calendars
     --reform <val>    Gregorian reform date (1752|gregorian|iso|julian)
     --iso             alias for --reform=iso
 -y, --year            show the whole year
 -Y, --twelve          show the next twelve months
 -w, --week[=<num>]    show US or ISO-8601 week numbers
 -v, --vertical        show day vertically instead of line
 -c, --columns <width> amount of columns to use
     --color[=<when>]  colorize messages (auto, always or never)
                         colors are enabled by default

 -h, --help            display this help
 -V, --version         display version

For more details see cal(1).

Thus, CAL.EXE -j gives me a calendar,
showing the day-of-the-year.

Here's my alias to enable cygwin,
execute cal.exe -j,
disable cygwin,
and reset the terminal colour.

Code:
E:\Utils>alias calj
cyg on & cal.exe -j & cyg off & color 07

Here's my library command to enable/disable cygwin,
Code:
E:\Utils>library /f cyg
utils.library$cyg {
@echo off
if %@search[sort.exe] eq C:\cygwin64\bin\sort.exe set cygwin=y
if %@search[sort.exe] eq C:\WINDOWS\system32\sort.exe set cygwin=n
::
:: Pre-pend the cygwin folder to the path
if %1 eq on .and. %cygwin eq n set path=c:\cygwin64\bin;%path%
::
:: Remove the cygwin folder from the path
if %1 eq off .and. %cygwin eq y path /d c:\cygwin64\bin
::
if %@search[sort.exe] eq C:\cygwin64\bin\sort.exe set cygwin=y
if %@search[sort.exe] eq C:\WINDOWS\system32\sort.exe set cygwin=n
}

1772814937037.webp


Ref: Enable/Disable Cygwin On Demand

Joe
 
Sometimes, though,
I need a calendar that shows the day of the year.
. . .
Here's my alias to enable cygwin,
execute cal.exe -j,
disable cygwin,
and reset the terminal colour.
You know, the people behind the Unix toolkit are pretty sharp, and the switches for Unix 'date' are very similar to Unix 'cal'.

I have defined unixdate as an alias to c:\tools\bin\date.exe (which I filched from Git for Windows). So I can do this:
Code:
[ 8:33] > unixdate -d 2026-09-09 +`%j `
252

[ 8:33] > unixdate +`%j` --date 2026-12-31
365

[ 8:33] > unixdate +"%%j"
071

[ 8:33] > unixdate +"%%j" --date "tomorrow"
072

You can use the short switch "-d" or the long form "--date" and put it in front or behind the +FORMAT string, and it will work just fine. Also, the FORMAT options are pretty smart!
 
Back
Top