Bob Kline wrote: > The date command reports the wrong ISO week number in some cases. For > example: > > $ date -d 2008-12-31 +%Y%V > 200801 > > Clearly the last day of the year can't be in the first week of that > year.
According to ISO 8601 it can. See the official standard for the authoritative details but wikipedia has a good summary. http://en.wikipedia.org/wiki/ISO_8601 Weeks begin with Monday and end on Sunday. Week 01 is the week with the year's first Thursday in it. The GNU Coreutils date %V documentation says: `%V' week number of year with Monday as first day of the week as a decimal (`01'...`53'). If the week containing January 1 has four or more days in the new year, then it is considered week 1; otherwise, it is week 53 of the previous year, and the next week is week 1. (See the ISO 8601 standard.) Perhaps for your purposes (you didn't say what you purpose was) you wanted to use %G%V? $ date -d 2008-12-31 +%G%V 200901 Personally I prefer %F (a GNU extension) best. $ date -d 2008-12-31 +%F 2008-12-31 Bob _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils