Re: Linux Date Command gives wrong year with +%g
lists.gnu.org
lists.gnu.org
It's always tough to deal with this kind of situation. Do you document it all over the place and hope users read it? Do you parse the command when it's first created and warn the user that %g is different than %Y? Do you just ignore the issue and deal with the small number of emails at the beginning of every year?
I think a combination of docs + automated checks is best depending on the circumstances.
I'm assuming that (1) the poster is warning others about this or (2) he finds it amusing that the response to "The year is wrong" is (roughly) "No, that's how the standard defines year. The output is right relative to that standard. Dates and times suck." (the last sentence is implied) or (3) both.
%G is replaced by a year as a decimal number with century. This
year is the one that contains the greater part of the week
(Monday as the first day of the week).
%g is replaced by the same year as in ``%G'', but as a decimal
number without century (00-99).
Makes sense to me. People should read the man pages more often before they jump to conclusions.Granted, that is more clear than man date on Linux (on OSX it doesn't define the format variables):
%g last two digits of year of ISO week number (see %G)
%G year of ISO week number (see %V); normally useful only with %V
%V ISO week number, with Monday as first day of week (01..53)I regularly see ISO weeks used to mark manufacturing dates, where they often offer the right levels of precision, as many processes run on week-long cycles. Often in stampings the year will be replaced by a letter code with an epoch particular to the company.
The ISO week date system is a leap week calendar system that is part of the ISO 8601 date and time standard. The system is used (mainly) in government and business for fiscal years, as well as in timekeeping.
For sources, see also "errata" on intuitive.com/wicked
when the correct time to use them is?
Basically amounts to personal preference since options can be formatted.