GNU bug report logs -
#10699
bug of `date`: why 1/1/2012 is the second week of 2012?
Previous Next
Reported by: "Wang, YuanTao" <ytwang <at> freewheel.tv>
Date: Thu, 2 Feb 2012 17:06:02 UTC
Severity: normal
Tags: notabug
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #15 received at 10699-done <at> debbugs.gnu.org (full text, mbox):
Thank you!
Yuantao Wang | Senior Engineer | FREEWHEEL
tel: +86 6231.9035 mobile: +86 135.2110.6828 skype: wangyuantao
www.freewheel.tv
SILICON VALLEY . NEW YORK . BEIJING . LONDON
-----Original Message-----
From: Eric Blake [mailto:eblake <at> redhat.com]
Sent: Friday, February 03, 2012 2:42 AM
Cc: Wang, YuanTao; 10699-done <at> debbugs.gnu.org
Subject: Re: bug#10699: bug of `date`: why 1/1/2012 is the second week of 2012?
On 02/02/2012 11:32 AM, Eric Blake wrote:
> The coreutils FAQ at
> https://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-wo
> rking-right_002e has more information, including a link to
> http://en.wikipedia.org/wiki/ISO_8601, which describes where ISO 8601
> week 1 starts:
>
>> There are mutually equivalent descriptions of week 01:
>>
>> the week with the year's first Thursday in it (the formal ISO definition),
>> the week with 4 January in it,
>> the first week with the majority (four or more) of its days in the starting year, and
>> the week starting with the Monday in the period 29 December - 4 January.
>>
>> If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is in week 52 or 53 of the previous year (there is no week 00). 28 December is always in the last week of its year.
>
> That means in ISO 8601 week numbering (%G%V), there is no week 0, days
> falling before week 1 are assigned to the last week of the previous
> year (likewise, days at the end of the calendar year can be assigned
> into week 1 of the next year). But since week-based years can be
> confusing if you aren't familiar with ISO, POSIX provides not one, but
> two alternatives. If you like ISO 8601 weeks starting on Monday, then
> the POSIX counterpart (%Y%W) is guaranteed to match the ISO week
> numbering for all days except those at the beginning or end of the
> calendar that ISO would assign into a different year, but where POSIX
> assigns them to week 0 or week 52/53 instead.
Correction - %W can list a different week than %V. A better way to look at it is that week 1 in all three systems is the first week that has a full 7 days assigned to the current year. Week 0 only exists if there are days that fall before week 1 but are still assigned to the current year, and if week 0 exists, it will have less than 7 days. Week 0 does not exist for the %V system, which instead shuffles which year things are assigned to.
--
Eric Blake eblake <at> redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
This bug report was last modified 13 years and 171 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.