From unknown Sun Aug 17 22:08:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#10699: bug of `date`: why 1/1/2012 is the second week of 2012? Resent-From: "Wang, YuanTao" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 02 Feb 2012 17:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 10699 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 10699@debbugs.gnu.org X-Debbugs-Original-To: "bug-coreutils@gnu.org" Received: via spool by submit@debbugs.gnu.org id=B.13282023614994 (code B ref -1); Thu, 02 Feb 2012 17:06:02 +0000 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" Date: Thu, 2 Feb 2012 02:25:59 -0600 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-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 unknown Sun Aug 17 22:08:36 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.428 (Entity 5.428) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: "Wang, YuanTao" Subject: bug#10699: closed (Re: bug#10699: bug of `date`: why 1/1/2012 is the second week of 2012?) Message-ID: References: <4F2AD65D.6010102@cs.ucla.edu> <912F6757A48DB24C9078E39E4B7B89314B7EA80C93@AUSP01VMBX30.collaborationhost.net> X-Gnu-PR-Message: they-closed 10699 X-Gnu-PR-Package: coreutils Reply-To: 10699@debbugs.gnu.org Date: Thu, 02 Feb 2012 18:32:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1328207522-13151-1" This is a multi-part message in MIME format... ------------=_1328207522-13151-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #10699: bug of `date`: why 1/1/2012 is the second week of 2012? which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 10699@debbugs.gnu.org. --=20 10699: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D10699 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1328207522-13151-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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. ------------=_1328207522-13151-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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_-- ------------=_1328207522-13151-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--