From unknown Sun Aug 17 09:09:56 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#10699 <10699@debbugs.gnu.org> To: bug#10699 <10699@debbugs.gnu.org> Subject: Status: bug of `date`: why 1/1/2012 is the second week of 2012? Reply-To: bug#10699 <10699@debbugs.gnu.org> Date: Sun, 17 Aug 2025 16:09:56 +0000 retitle 10699 bug of `date`: why 1/1/2012 is the second week of 2012? reassign 10699 coreutils submitter 10699 "Wang, YuanTao" severity 10699 normal tag 10699 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 02 12:06:01 2012 Received: (at submit) by debbugs.gnu.org; 2 Feb 2012 17:06:01 +0000 Received: from localhost ([127.0.0.1]:51061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt06i-0001IQ-Uj for submit@debbugs.gnu.org; Thu, 02 Feb 2012 12:06:01 -0500 Received: from eggs.gnu.org ([140.186.70.92]:46644) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rsryg-0003g9-VQ for submit@debbugs.gnu.org; Thu, 02 Feb 2012 03:25:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rsry6-0004aN-Cr for submit@debbugs.gnu.org; Thu, 02 Feb 2012 03:24:39 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([140.186.70.17]:52056) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rsry6-0004aJ-BM for submit@debbugs.gnu.org; Thu, 02 Feb 2012 03:24:34 -0500 Received: from eggs.gnu.org ([140.186.70.92]:35658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rsry2-00035B-95 for bug-coreutils@gnu.org; Thu, 02 Feb 2012 03:24:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rsrxy-0004ZX-4Q for bug-coreutils@gnu.org; Thu, 02 Feb 2012 03:24:30 -0500 Received: from mail160.messagelabs.com ([216.82.253.99]:20512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rsrxx-0004ZJ-RB for bug-coreutils@gnu.org; Thu, 02 Feb 2012 03:24:26 -0500 X-Env-Sender: ytwang@freewheel.tv X-Msg-Ref: server-11.tower-160.messagelabs.com!1328171062!46057848!1 X-Originating-IP: [216.166.12.98] X-StarScan-Version: 6.4.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29074 invoked from network); 2 Feb 2012 08:24:22 -0000 Received: from out001.collaborationhost.net (HELO out001.collaborationhost.net) (216.166.12.98) by server-11.tower-160.messagelabs.com with RC4-SHA encrypted SMTP; 2 Feb 2012 08:24:22 -0000 Received: from AUSP01VMBX30.collaborationhost.net ([10.2.12.44]) by AUSP01MHUB07.collaborationhost.net ([10.2.8.242]) with mapi; Thu, 2 Feb 2012 02:24:21 -0600 From: "Wang, YuanTao" To: "bug-coreutils@gnu.org" Date: Thu, 2 Feb 2012 02:25:59 -0600 Subject: bug of `date`: why 1/1/2012 is the second week of 2012? Thread-Topic: bug of `date`: why 1/1/2012 is the second week of 2012? Thread-Index: AczhhEq0rwVIClw7TnmKiR3MDOFdUg== Message-ID: <912F6757A48DB24C9078E39E4B7B89314B7EA80C93@AUSP01VMBX30.collaborationhost.net> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: zh-CN, en-US Content-Type: multipart/alternative; boundary="_000_912F6757A48DB24C9078E39E4B7B89314B7EA80C93AUSP01VMBX30c_" MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 02 Feb 2012 12:05:59 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) --_000_912F6757A48DB24C9078E39E4B7B89314B7EA80C93AUSP01VMBX30c_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable $ date -d "2012-01-01 00:00:00" +%U 01 but in "man date" %U week number of year, with Sunday as first day of week (00..53) Is it a bug? $ uname -r 2.6.18-128.1.6.el5xen --_000_912F6757A48DB24C9078E39E4B7B89314B7EA80C93AUSP01VMBX30c_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

$ date -d "2012-01-01 00:00= :00" +%U

= 01

 =

but in “man = date”

%U=      week number of year, with Sunday as first day of w= eek (00..53)

<= o:p> 

Is it a = bug?

&nbs= p;

$ uname -r<= /o:p>

2.6.18-128.1.6.el5x= en

 =

= --_000_912F6757A48DB24C9078E39E4B7B89314B7EA80C93AUSP01VMBX30c_-- From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 02 13:31:32 2012 Received: (at 10699-done) by debbugs.gnu.org; 2 Feb 2012 18:31:32 +0000 Received: from localhost ([127.0.0.1]:51143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt1RT-0003PK-Gp for submit@debbugs.gnu.org; Thu, 02 Feb 2012 13:31:32 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:49835) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt1RQ-0003P5-Ii for 10699-done@debbugs.gnu.org; Thu, 02 Feb 2012 13:31:30 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id B2F8CA60002; Thu, 2 Feb 2012 10:30:54 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mmMZVcqIdXR6; Thu, 2 Feb 2012 10:30:54 -0800 (PST) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 0E46E39E8010; Thu, 2 Feb 2012 10:30:54 -0800 (PST) Message-ID: <4F2AD65D.6010102@cs.ucla.edu> Date: Thu, 02 Feb 2012 10:30:53 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: "Wang, YuanTao" Subject: Re: bug#10699: bug of `date`: why 1/1/2012 is the second week of 2012? References: <912F6757A48DB24C9078E39E4B7B89314B7EA80C93@AUSP01VMBX30.collaborationhost.net> In-Reply-To: <912F6757A48DB24C9078E39E4B7B89314B7EA80C93@AUSP01VMBX30.collaborationhost.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10699-done Cc: 10699-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 02/02/2012 12:25 AM, Wang, YuanTao wrote: > $ date -d "2012-01-01 00:00:00" +%U > 01 > > but in "man date" > %U week number of year, with Sunday as first day of week (00..53) > > Is it a bug? No. As the manual (which has more detail) says, "Days in a new year preceding the first Sunday are in week zero." In 2012 there are no such days, so January 1 is week 1. From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 02 13:32:46 2012 Received: (at control) by debbugs.gnu.org; 2 Feb 2012 18:32:46 +0000 Received: from localhost ([127.0.0.1]:51153 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt1Sf-0003RX-KF for submit@debbugs.gnu.org; Thu, 02 Feb 2012 13:32:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46073) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt1Sa-0003RG-P8; Thu, 02 Feb 2012 13:32:43 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q12IWB3f020121 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Feb 2012 13:32:11 -0500 Received: from [10.3.113.27] (ovpn-113-27.phx2.redhat.com [10.3.113.27]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q12IWABD006642; Thu, 2 Feb 2012 13:32:10 -0500 Message-ID: <4F2AD6AA.3090207@redhat.com> Date: Thu, 02 Feb 2012 11:32:10 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: "Wang, YuanTao" Subject: Re: bug#10699: bug of `date`: why 1/1/2012 is the second week of 2012? References: <912F6757A48DB24C9078E39E4B7B89314B7EA80C93@AUSP01VMBX30.collaborationhost.net> In-Reply-To: <912F6757A48DB24C9078E39E4B7B89314B7EA80C93@AUSP01VMBX30.collaborationhost.net> X-Enigmail-Version: 1.3.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig64A1D0AEB22CEDA3ED617E77" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: control Cc: 10699-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig64A1D0AEB22CEDA3ED617E77 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable tag 10699 notabug thanks On 02/02/2012 01:25 AM, Wang, YuanTao wrote: > $ date -d "2012-01-01 00:00:00" +%U > 01 >=20 > but in "man date" > %U week number of year, with Sunday as first day of week (00..53) >=20 > Is it a bug? No, it is behavior required by POSIX, http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html. The coreutils FAQ at https://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-worki= ng-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: >=20 > the week with the year's first Thursday in it (the formal ISO defin= ition), > 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 =96 4 J= anuary. >=20 > If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in w= eek 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. And if you like weeks starting on Sunday instead of Monday, then the POSIX counterpart (%Y%U) shifts things to start week 1 on Sunday instead of Monday, again with week 0 and week 53 rather than rolling things into different years. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig64A1D0AEB22CEDA3ED617E77 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPKtaqAAoJEKeha0olJ0NqzPAH/i8QOpCbxwlSf9pY1+0b4rCb pv7zFkCie+MhU9aa5HAE5L0rxEWu7Ua/y9Me/h7oQ2D2RQv9+3Z6En1ACqOVqvcL kgZWnqHKL5EK8VXRsijKuQHl+xwRAbyVsaSgPVtba/iKPwZaFqGSLMBpCeycOCOy 0D071xny6HmWkGl73UqCbLTBCcN5AmppTE87zrOeKjPEhZUkddr/QVKE39iytG+6 8qbPu/gwBVfuEEsrjmch4JfQQlaqPigONNAabI5f4eA0tsHhagcpKTNzTrkWX1U8 BdaXsx7CWu50x4nFtVN2J/5+s9Mv+12ap/l2DE74McOB+vTKzVfDGm7KZEdpstc= =rdOj -----END PGP SIGNATURE----- --------------enig64A1D0AEB22CEDA3ED617E77-- From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 02 13:42:55 2012 Received: (at 10699-done) by debbugs.gnu.org; 2 Feb 2012 18:42:55 +0000 Received: from localhost ([127.0.0.1]:51158 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt1cU-0003gT-Rm for submit@debbugs.gnu.org; Thu, 02 Feb 2012 13:42:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46741) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt1cQ-0003gK-R5 for 10699-done@debbugs.gnu.org; Thu, 02 Feb 2012 13:42:52 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q12IgLo3024269 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Feb 2012 13:42:21 -0500 Received: from [10.3.113.27] (ovpn-113-27.phx2.redhat.com [10.3.113.27]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q12IgKFx011716; Thu, 2 Feb 2012 13:42:20 -0500 Message-ID: <4F2AD90C.6020405@redhat.com> Date: Thu, 02 Feb 2012 11:42:20 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 Subject: Re: bug#10699: bug of `date`: why 1/1/2012 is the second week of 2012? References: <912F6757A48DB24C9078E39E4B7B89314B7EA80C93@AUSP01VMBX30.collaborationhost.net> <4F2AD6AA.3090207@redhat.com> In-Reply-To: <4F2AD6AA.3090207@redhat.com> X-Enigmail-Version: 1.3.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigB14BA0E0D6CDBFC4DAC533E0" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: 10699-done Cc: 10699-done@debbugs.gnu.org, "Wang, YuanTao" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB14BA0E0D6CDBFC4DAC533E0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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-wor= king-right_002e > has more information, including a link to > http://en.wikipedia.org/wiki/ISO_8601, which describes where ISO 8601 > week 1 starts: >=20 >> There are mutually equivalent descriptions of week 01: >> >> the week with the year's first Thursday in it (the formal ISO defi= nition), >> 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 =96 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 5= 2 or 53 of the previous year (there is no week 00). 28 December is always= in the last week of its year. >=20 > 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 yea= r > (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. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigB14BA0E0D6CDBFC4DAC533E0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPKtkMAAoJEKeha0olJ0NqQLkH/jIyERS/awiq9F+TXEnUCcI0 nfH6zK5yo2CBM1DCZOjnQRgbvlFNRbw1Q5qUAL6Y95fWxUa5fnWINECk7cu99qV5 FAxP1WWVYDHDOQP+9otDVIGuzwfxuySvQQKjH0hQZlAcJroyNH03Tv1ec5DF9h10 6jDGa7Qjpf6nygSb1LdFC+8eYcvhneqT80exHDgM9vLDcPmG6zLqzNrVPvlzBxbq Ch0giyXWyZKK93cma3lgymQySBZeLOvousV6AiTHg6R1tR0EiD+3KCHuRIvgT57K L6AdQJihC8xhlExJi61kyAEvuhmDqH+b7URxXZ65qKO/c4lKKr+Q/3XA5AKbcWs= =Y0Og -----END PGP SIGNATURE----- --------------enigB14BA0E0D6CDBFC4DAC533E0-- From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 02 20:25:29 2012 Received: (at 10699-done) by debbugs.gnu.org; 3 Feb 2012 01:25:29 +0000 Received: from localhost ([127.0.0.1]:51449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt7u5-0006sU-3l for submit@debbugs.gnu.org; Thu, 02 Feb 2012 20:25:29 -0500 Received: from mail127.messagelabs.com ([216.82.250.115]:43533) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rt7u0-0006sI-R5 for 10699-done@debbugs.gnu.org; Thu, 02 Feb 2012 20:25:26 -0500 X-Env-Sender: ytwang@freewheel.tv X-Msg-Ref: server-8.tower-127.messagelabs.com!1328232274!44788281!11 X-Originating-IP: [216.166.12.178] X-StarScan-Version: 6.5.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25235 invoked from network); 3 Feb 2012 01:24:50 -0000 Received: from out001.collaborationhost.net (HELO out001.collaborationhost.net) (216.166.12.178) by server-8.tower-127.messagelabs.com with RC4-SHA encrypted SMTP; 3 Feb 2012 01:24:50 -0000 Received: from AUSP01VMBX30.collaborationhost.net ([10.2.12.44]) by AUSP01MHUB04.collaborationhost.net ([10.2.0.189]) with mapi; Thu, 2 Feb 2012 19:24:43 -0600 From: "Wang, YuanTao" To: Eric Blake Date: Thu, 2 Feb 2012 19:25:41 -0600 Subject: RE: bug#10699: bug of `date`: why 1/1/2012 is the second week of 2012? Thread-Topic: bug#10699: bug of `date`: why 1/1/2012 is the second week of 2012? Thread-Index: Aczh2mkQhV4vUQR4SxCU6Hg8ZDj94gAOCgKA Message-ID: <912F6757A48DB24C9078E39E4B7B89314B7EA810B1@AUSP01VMBX30.collaborationhost.net> References: <912F6757A48DB24C9078E39E4B7B89314B7EA80C93@AUSP01VMBX30.collaborationhost.net> <4F2AD6AA.3090207@redhat.com> <4F2AD90C.6020405@redhat.com> In-Reply-To: <4F2AD90C.6020405@redhat.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: zh-CN, en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 10699-done Cc: "10699-done@debbugs.gnu.org" <10699-done@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Thank you! Yuantao Wang | Senior Engineer | FREEWHEEL tel: +86 6231.9035 =A0mobile: +86 135.2110.6828 =A0skype: wangyuantao www.freewheel.tv=20 SILICON VALLEY . NEW YORK . BEIJING . LONDON -----Original Message----- From: Eric Blake [mailto:eblake@redhat.com]=20 Sent: Friday, February 03, 2012 2:42 AM Cc: Wang, YuanTao; 10699-done@debbugs.gnu.org Subject: Re: bug#10699: bug of `date`: why 1/1/2012 is the second week of 2= 012? 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=20 > http://en.wikipedia.org/wiki/ISO_8601, which describes where ISO 8601=20 > week 1 starts: >=20 >> There are mutually equivalent descriptions of week 01: >> >> the week with the year's first Thursday in it (the formal ISO defini= tion), >> the week with 4 January in it, >> the first week with the majority (four or more) of its days in the s= tarting year, and >> the week starting with the Monday in the period 29 December - 4 Janu= ary. >> >> If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in we= ek 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 th= e last week of its year. >=20 > That means in ISO 8601 week numbering (%G%V), there is no week 0, days=20 > falling before week 1 are assigned to the last week of the previous=20 > year (likewise, days at the end of the calendar year can be assigned=20 > into week 1 of the next year). But since week-based years can be=20 > confusing if you aren't familiar with ISO, POSIX provides not one, but=20 > two alternatives. If you like ISO 8601 weeks starting on Monday, then=20 > the POSIX counterpart (%Y%W) is guaranteed to match the ISO week=20 > numbering for all days except those at the beginning or end of the=20 > calendar that ISO would assign into a different year, but where POSIX=20 > 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 t= hat fall before week 1 but are still assigned to the current year, and if w= eek 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. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org From unknown Sun Aug 17 09:09:56 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 02 Mar 2012 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator