Bob Kline <bkline <at> rksystems.com> writes: > > The date command reports the wrong ISO week number in some cases. For > example: > > $ date -d 2008-12-31 +%Y%V > 200801
Not a bug in date, but in your misuse of incompatible formats. 2008-12-31 is in the first ISO week of 2009, as evidenced by: $ date -d 2008-12-31 +%G%V 200901 $ date -d 2009-01-01 +%G%V 200901 The ISO week starts on Monday, and is attributed to the year that contains four or more days of the week; it can be 01-53 inclusive (but 53 is rare). Perhaps you wanted the more traditional week number: $ date -d 2008-12-31 +%Y%U 200852 $ date -d 2009-01-01 +%Y%U 200900 Here, the week starts on Sunday, the range is 00-53, and no days are attributed to an adjacent year; week 01 is the first full week of the year. This is specified by POSIX: http://www.opengroup.org/onlinepubs/9699919799/utilities/date.html In short, %G and %V go together, %Y and %U go together, and any other combination causes confusion. Perhaps we should try to mention this in the usage text somehow? There seems to always be a rash of "bug" reports about date at the turn of the year (and also around daylight savings changes), due to the large number of people who don't realize the subtleties involved. Perhaps we should create a FAQ entry with the most common of these reports. -- Eric Blake _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils