I am observing what appears to be strange behavior in the “date” command. “date” displays today correctly and will accept --date input. However, if I restrict the output using the “+%” operator I get strange results.
freda@localhost.heavy1] ~ $ date
Wed 12 Feb 12:58:28 MST 2025
freda@localhost.heavy1] ~ $ date --date sunday
Sun 16 Feb 00:00:00 MST 2025
freda@localhost.heavy1] ~ $
freda@localhost.heavy1] ~ $ date
Wed 12 Feb 12:58:28 MST 2025
freda@localhost.heavy1] ~ $
freda@localhost.heavy1] ~ $ date --date sunday +%u
7
freda@localhost.heavy1] ~ $ date --date sunday +%w
0
freda@localhost.heavy1] ~ $ date +%u
3
freda@localhost.heavy1] ~ $ date +%w
3
freda@localhost.heavy1] ~ $
From the man date command
FORMAT controls the output. Interpreted sequences are:
.
.
%u day of week (1..7); 1 is Monday
.
.
%w day of week (0..6); 0 is Sunday
Is this just me or have I found a real misbehavior?