Open omasanori opened 2 years ago
It would be nice for us to explain the difference of %W
vs %V
, and %Y
vs %G
. It's not even clear to me, lol.
Also, linking a man page here because the one on MacOS is not great: https://man7.org/linux/man-pages/man1/date.1.html
Indeed. I had checked https://en.m.wikipedia.org/wiki/ISO_week_date and musl libc's strftime
few days ago and am still confused. The calculation in C is slightly different from that in the Wikipedia article because January 1st is not 1
but 0
and Sunday is not 7
but 0
, which makes the situation worse...
Just a guess from manpages, confirmation needed.It works!date +'%G-W%V'
date +'%G-W%V-%u'
date +'%Y-%j'
strftime
as defined in ISO C99 or later supports the formats above. Even on platforms with C90 standard library,date(1)
in GNU coreutils uses gnulib's implementation that provides them portably.