From unknown Fri Jun 20 20:10:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13372: bug in date with last week calculation Resent-From: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 07 Jan 2013 00:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13372 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 13372@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Reply-To: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Received: via spool by submit@debbugs.gnu.org id=B.135751974827419 (code B ref -1); Mon, 07 Jan 2013 00:50:01 +0000 Received: (at submit) by debbugs.gnu.org; 7 Jan 2013 00:49:08 +0000 Received: from localhost ([127.0.0.1]:33345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts0tm-00078B-TJ for submit@debbugs.gnu.org; Sun, 06 Jan 2013 19:49:08 -0500 Received: from eggs.gnu.org ([208.118.235.92]:42963) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Trzxv-0005gN-47 for submit@debbugs.gnu.org; Sun, 06 Jan 2013 18:49:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Trzxl-0005UW-IN for submit@debbugs.gnu.org; Sun, 06 Jan 2013 18:49:13 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:42623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Trzxl-0005UQ-FR for submit@debbugs.gnu.org; Sun, 06 Jan 2013 18:49:09 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Trzxg-0003hw-JK for bug-coreutils@gnu.org; Sun, 06 Jan 2013 18:49:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Trzxc-0005Tj-VJ for bug-coreutils@gnu.org; Sun, 06 Jan 2013 18:49:04 -0500 Received: from mx3-phx2.redhat.com ([209.132.183.24]:37670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Trzxc-0005Td-O4 for bug-coreutils@gnu.org; Sun, 06 Jan 2013 18:49:00 -0500 Received: from zmail09.collab.prod.int.phx2.redhat.com (zmail09.collab.prod.int.phx2.redhat.com [10.5.83.11]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r06NmxGP030384 for ; Sun, 6 Jan 2013 18:48:59 -0500 Date: Sun, 6 Jan 2013 18:48:59 -0500 (EST) From: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Message-ID: <1429027069.88842.1357516139363.JavaMail.root@redhat.com> In-Reply-To: <668248222.88795.1357516077121.JavaMail.root@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.64.0.161] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - GC23 (Linux)/7.2.0_GA_2669) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.5 (---) X-Mailman-Approved-At: Sun, 06 Jan 2013 19:49:04 -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 (----) Hi,=20 I'm getting week number 53 when trying to get last week on Mon Jan 7 09:46= :19 EST 2013: $ date Mon Jan 7 09:46:19 EST 2013 $ date -d'last week' +%W 53 Expecting to get week 1 Many thanks! --=20 Tomas Daba=C5=A1inskas | Engineering Content Services | Red Hat Asia Pacifi= c From unknown Fri Jun 20 20:10:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13372: bug in date with last week calculation Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 07 Jan 2013 02:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13372 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Cc: 13372@debbugs.gnu.org Received: via spool by 13372-submit@debbugs.gnu.org id=B13372.13575240342165 (code B ref 13372); Mon, 07 Jan 2013 02:01:02 +0000 Received: (at 13372) by debbugs.gnu.org; 7 Jan 2013 02:00:34 +0000 Received: from localhost ([127.0.0.1]:33374 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts20u-0000Yo-Ao for submit@debbugs.gnu.org; Sun, 06 Jan 2013 21:00:33 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:50972) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts20p-0000YW-Gw for 13372@debbugs.gnu.org; Sun, 06 Jan 2013 21:00:29 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 4C886A60002; Sun, 6 Jan 2013 18:00:20 -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 gQ6qsLVTQsKS; Sun, 6 Jan 2013 18:00:19 -0800 (PST) Received: from [192.168.1.9] (pool-71-189-154-249.lsanca.fios.verizon.net [71.189.154.249]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id BE707A60001; Sun, 6 Jan 2013 18:00:19 -0800 (PST) Message-ID: <50EA2C33.9000902@cs.ucla.edu> Date: Sun, 06 Jan 2013 18:00:19 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 References: <1429027069.88842.1357516139363.JavaMail.root@redhat.com> In-Reply-To: <1429027069.88842.1357516139363.JavaMail.root@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.5 (-) 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.5 (-) On 01/06/2013 03:48 PM, Tomas Daba=C5=A1inskas wrote: > $ date > Mon Jan 7 09:46:19 EST 2013 Something odd with your time zone setting? As I write this, the current time is Sun Jan 6 20:59:42 EST 2013. From unknown Fri Jun 20 20:10:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13372: bug in date with last week calculation References: <1429027069.88842.1357516139363.JavaMail.root@redhat.com> Resent-From: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 07 Jan 2013 02:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13372 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: 13372@debbugs.gnu.org Reply-To: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Received: via spool by 13372-submit@debbugs.gnu.org id=B13372.13575251363885 (code B ref 13372); Mon, 07 Jan 2013 02:19:02 +0000 Received: (at 13372) by debbugs.gnu.org; 7 Jan 2013 02:18:56 +0000 Received: from localhost ([127.0.0.1]:33392 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts2Ih-00010c-Qs for submit@debbugs.gnu.org; Sun, 06 Jan 2013 21:18:56 -0500 Received: from mx4-phx2.redhat.com ([209.132.183.25]:34306) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts2Ie-00010S-Qn for 13372@debbugs.gnu.org; Sun, 06 Jan 2013 21:18:54 -0500 Received: from zmail09.collab.prod.int.phx2.redhat.com (zmail09.collab.prod.int.phx2.redhat.com [10.5.83.11]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r072Iewa030183; Sun, 6 Jan 2013 21:18:40 -0500 Date: Sun, 6 Jan 2013 21:18:40 -0500 (EST) From: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Message-ID: <225363658.105742.1357525120512.JavaMail.root@redhat.com> In-Reply-To: <50EA2C33.9000902@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.64.0.161] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - GC23 (Linux)/7.2.0_GA_2669) X-Spam-Score: -4.2 (----) 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 (----) ----- Original Message ----- > Something odd with your time zone setting? > As I write this, the current time is > Sun Jan 6 20:59:42 EST 2013. >=20 Paul,=20 Many thanks for getting back. The time zone I'm using is GMT+10 (Australian East Std time). I'm sorry, I should have clarified this in my bug report, I don't think it'= s timezone related tough... Regards, --=20 Tomas Daba=C5=A1inskas | Engineering Content Services | Red Hat Asia Pacifi= c From unknown Fri Jun 20 20:10:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13372: bug in date with last week calculation Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 07 Jan 2013 02:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13372 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Cc: 13372@debbugs.gnu.org Received: via spool by 13372-submit@debbugs.gnu.org id=B13372.13575265266065 (code B ref 13372); Mon, 07 Jan 2013 02:43:02 +0000 Received: (at 13372) by debbugs.gnu.org; 7 Jan 2013 02:42:06 +0000 Received: from localhost ([127.0.0.1]:33406 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts2f8-0001Zm-Ly for submit@debbugs.gnu.org; Sun, 06 Jan 2013 21:42:06 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:51947) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts2f6-0001ZH-2g for 13372@debbugs.gnu.org; Sun, 06 Jan 2013 21:42:05 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 34035A60002; Sun, 6 Jan 2013 18:41:57 -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 BazU5sSZ3jaC; Sun, 6 Jan 2013 18:41:56 -0800 (PST) Received: from [192.168.1.9] (pool-71-189-154-249.lsanca.fios.verizon.net [71.189.154.249]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id DF217A60001; Sun, 6 Jan 2013 18:41:56 -0800 (PST) Message-ID: <50EA35F4.9000800@cs.ucla.edu> Date: Sun, 06 Jan 2013 18:41:56 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 References: <225363658.105742.1357525120512.JavaMail.root@redhat.com> In-Reply-To: <225363658.105742.1357525120512.JavaMail.root@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.5 (-) 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.5 (-) On 01/06/2013 06:18 PM, Tomas Daba=C5=A1inskas wrote: > The time zone I'm using is GMT+10 (Australian East Std time). Ah, in that case week 53 is correct, no? $ export TZ=3DAustralia/Sydney; date; date -d'last week'; date -d'last we= ek' +%W Mon Jan 7 13:41:02 EST 2013 Mon Dec 31 13:41:02 EST 2012 53 From unknown Fri Jun 20 20:10:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13372: bug in date with last week calculation References: <1429027069.88842.1357516139363.JavaMail.root@redhat.com> Resent-From: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 07 Jan 2013 02:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13372 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: 13372@debbugs.gnu.org Reply-To: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Received: via spool by 13372-submit@debbugs.gnu.org id=B13372.13575267766474 (code B ref 13372); Mon, 07 Jan 2013 02:47:01 +0000 Received: (at 13372) by debbugs.gnu.org; 7 Jan 2013 02:46:16 +0000 Received: from localhost ([127.0.0.1]:33410 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts2j9-0001gJ-60 for submit@debbugs.gnu.org; Sun, 06 Jan 2013 21:46:16 -0500 Received: from mx3-phx2.redhat.com ([209.132.183.24]:47646) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts2j7-0001g4-51 for 13372@debbugs.gnu.org; Sun, 06 Jan 2013 21:46:14 -0500 Received: from zmail09.collab.prod.int.phx2.redhat.com (zmail09.collab.prod.int.phx2.redhat.com [10.5.83.11]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r072jxWQ014641; Sun, 6 Jan 2013 21:45:59 -0500 Date: Sun, 6 Jan 2013 21:45:59 -0500 (EST) From: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Message-ID: <579006261.109545.1357526759262.JavaMail.root@redhat.com> In-Reply-To: <50EA35F4.9000800@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.64.0.161] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - GC23 (Linux)/7.2.0_GA_2669) X-Spam-Score: -4.2 (----) 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 (----) ----- Original Message ----- > Ah, in that case week 53 is correct, no? >=20 > $ export TZ=3DAustralia/Sydney; date; date -d'last week'; date -d'last > week' +%W > Mon Jan 7 13:41:02 EST 2013 > Mon Dec 31 13:41:02 EST 2012 > 53 >=20 >=20 Paul, I'm using coreutils v8.4 so I think that could be my problem... --=20 Tomas Daba=C5=A1inskas | Engineering Content Services | Red Hat Asia Pacifi= c From unknown Fri Jun 20 20:10:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13372: bug in date with last week calculation Resent-From: Bob Proulx Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 07 Jan 2013 06:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13372 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Cc: 13372@debbugs.gnu.org Received: via spool by 13372-submit@debbugs.gnu.org id=B13372.135754185229909 (code B ref 13372); Mon, 07 Jan 2013 06:58:02 +0000 Received: (at 13372) by debbugs.gnu.org; 7 Jan 2013 06:57:32 +0000 Received: from localhost ([127.0.0.1]:33510 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts6eJ-0007mL-BM for submit@debbugs.gnu.org; Mon, 07 Jan 2013 01:57:31 -0500 Received: from joseki.proulx.com ([216.17.153.58]:47587) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ts6eE-0007m9-0l for 13372@debbugs.gnu.org; Mon, 07 Jan 2013 01:57:28 -0500 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id B1A3521173; Sun, 6 Jan 2013 23:57:22 -0700 (MST) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 4D9E42DCD8; Sun, 6 Jan 2013 23:57:22 -0700 (MST) Date: Sun, 6 Jan 2013 23:57:22 -0700 From: Bob Proulx Message-ID: <20130107065721.GA6686@hysteria.proulx.com> References: <668248222.88795.1357516077121.JavaMail.root@redhat.com> <1429027069.88842.1357516139363.JavaMail.root@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1429027069.88842.1357516139363.JavaMail.root@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.8 (/) 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: 0.8 (/) Tomas Daba=C5=A1inskas wrote: > I'm getting week number 53 when trying to get last week on > Mon Jan 7 09:46:19 EST 2013: > > $ date > Mon Jan 7 09:46:19 EST 2013 > $ date -d'last week' +%W > 53 > > Expecting to get week 1 You are using %W which is described as: `%W' week number of year, with Monday as first day of week (`00'...`53'). Days in a new year preceding the first Monday are in week zero. And so: December 2012 =20 Mo Tu We Th Fr Sa Su 24 25 26 27 28 29 30 <-- week 52 31 <-- week 53 January 2013 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 <-- week 0 7 8 9 10 11 12 13 <-- week 1 14 15 16 17 18 19 20 <-- week 2 21 22 23 24 25 26 27 28 29 30 31 Since you are reporting your current time as Jan 7 then Dec 31 would be last week. Dec 31 would be week 53. $ env TZ=3DAustralia/Sydney date -d 'last week' -R Mon, 31 Dec 2012 16:59:04 +1100 And so: $ env TZ=3DAustralia/Sydney date -d 'last week' +%W 53 $ env TZ=3DAustralia/Sydney date -d 'Dec 31 2012 12:00 +0000' +%W 53 There are multiple different definitions for week numbers depending upon weeks starting on Sunday, starting on Monday, and so forth. Also related are: `%U' week number of year, with Sunday as the first day of the week (`00'...`53'). Days in a new year preceding the first Sunday are in week zero. `%V' ISO week number, that is, the week number of year, with Monday as the first day of the week (`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.) You might want to look at the strftime man page for an alternate description: man 3 strftime %U The week number of the current year as a decimal number, = range 00 to 53, starting with the first Sunday as the first da= y of week 01. See also %V and %W. %V The ISO 8601 week number (see NOTES) of the current year= as a decimal number, range 01 to 53, where week 1 is the first = week that has at least 4 days in the new year. See also %U an= d %W. (SU) %W The week number of the current year as a decimal number, = range 00 to 53, starting with the first Monday as the first da= y of week 01. ISO 8601 Week Dates %G, %g, and %V yield values calculated from the week-based year de= fined by the ISO 8601 standard. In this system, weeks start on a Monday= , and are numbered from 01, for the first week, up to 52 or 53, for the = last week. Week 1 is the first week where four or more days fall withi= n the new year (or, synonymously, week 01 is: the first week of the year= that contains a Thursday; or, the week that has 4 January in it). = When three of fewer days of the first calendar week of the new year = fall within that year, then the ISO 8601 week-based system counts those= days as part of week 53 of the preceding year. For example, 1 January = 2010 is a Friday, meaning that just three days of that calendar week fa= ll in 2010. Thus, the ISO 8601 week-based system considers these days t= o be part of week 53 (%V) of the year 2009 (%G) ; week 01 of ISO 8601= year 2010 starts on Monday, 4 January 2010. Perhaps you are looking for the ISO week date %V? And if just doing calculations I suggest using UTC. $ date -u -d 'Dec 31 2012 12:00 +0000' +%V 01 The 'ncal' program provides a useful but unusual way to display the ISO week numbers: $ ncal -A 1 -w 12 2012 December 2012 January 2013 Su 2 9 16 23 30 6 13 20 27 Mo 3 10 17 24 31 7 14 21 28 Tu 4 11 18 25 1 8 15 22 29 We 5 12 19 26 2 9 16 23 30 Th 6 13 20 27 3 10 17 24 31 Fr 7 14 21 28 4 11 18 25 Sa 1 8 15 22 29 5 12 19 26 48 49 50 51 52 1 1 2 3 4 5 You should also read the FAQ: http://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-work= ing-right_002e No one is ever happy with week numbers. Bob From unknown Fri Jun 20 20:10:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13372: bug in date with last week calculation References: <1429027069.88842.1357516139363.JavaMail.root@redhat.com> Resent-From: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 07 Jan 2013 23:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13372 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Bob Proulx Cc: 13372@debbugs.gnu.org Reply-To: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Received: via spool by 13372-submit@debbugs.gnu.org id=B13372.135760170817526 (code B ref 13372); Mon, 07 Jan 2013 23:36:01 +0000 Received: (at 13372) by debbugs.gnu.org; 7 Jan 2013 23:35:08 +0000 Received: from localhost ([127.0.0.1]:55740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TsMDj-0004Yb-FU for submit@debbugs.gnu.org; Mon, 07 Jan 2013 18:35:07 -0500 Received: from mx4-phx2.redhat.com ([209.132.183.25]:33320) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TsMDg-0004YT-DF for 13372@debbugs.gnu.org; Mon, 07 Jan 2013 18:35:06 -0500 Received: from zmail09.collab.prod.int.phx2.redhat.com (zmail09.collab.prod.int.phx2.redhat.com [10.5.83.11]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r07NZ2vj021432; Mon, 7 Jan 2013 18:35:02 -0500 Date: Mon, 7 Jan 2013 18:35:02 -0500 (EST) From: Tomas =?UTF-8?Q?Daba=C5=A1inskas?= Message-ID: <1169310300.538379.1357601702659.JavaMail.root@redhat.com> In-Reply-To: <20130107065721.GA6686@hysteria.proulx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.64.0.161] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - GC23 (Linux)/7.2.0_GA_2669) X-Spam-Score: -4.2 (----) 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.0 (-----) ----- Original Message ----- > You are using %W which is described as: >=20 > `%W' > week number of year, with Monday as first day of week > (`00'...`53'). Days in a new year preceding the first Monday > are > in week zero. >=20 > And so: >=20 > December 2012 > Mo Tu We Th Fr Sa Su > 24 25 26 27 28 29 30 <-- week 52 > 31 <-- week 53 > January 2013 > Mo Tu We Th Fr Sa Su > 1 2 3 4 5 6 <-- week 0 > 7 8 9 10 11 12 13 <-- week 1 > 14 15 16 17 18 19 20 <-- week 2 > 21 22 23 24 25 26 27 > 28 29 30 31 >=20 > Since you are reporting your current time as Jan 7 then Dec 31 would > be last week. Dec 31 would be week 53. >=20 > $ env TZ=3DAustralia/Sydney date -d 'last week' -R > Mon, 31 Dec 2012 16:59:04 +1100 >=20 > And so: >=20 > $ env TZ=3DAustralia/Sydney date -d 'last week' +%W > 53 >=20 > $ env TZ=3DAustralia/Sydney date -d 'Dec 31 2012 12:00 +0000' +%W > 53 >=20 > There are multiple different definitions for week numbers depending > upon weeks starting on Sunday, starting on Monday, and so forth. >=20 > Also related are: >=20 > `%U' > week number of year, with Sunday as the first day of the week > (`00'...`53'). Days in a new year preceding the first Sunday > are > in week zero. >=20 > `%V' > ISO week number, that is, the week number of year, with Monday > as > the first day of the week (`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.) >=20 > You might want to look at the strftime man page for an alternate > description: >=20 > man 3 strftime >=20 > %U The week number of the current year as a decimal > number, range > 00 to 53, starting with the first Sunday as the first > day of > week 01. See also %V and %W. >=20 > %V The ISO 8601 week number (see NOTES) of the current > year as a > decimal number, range 01 to 53, where week 1 is the > first week > that has at least 4 days in the new year. See also > %U and %W. > (SU) >=20 > %W The week number of the current year as a decimal > number, range > 00 to 53, starting with the first Monday as the first > day of > week 01. >=20 > ISO 8601 Week Dates > %G, %g, and %V yield values calculated from the week-based > year defined > by the ISO 8601 standard. In this system, weeks start on a > Monday, and > are numbered from 01, for the first week, up to 52 or 53, for > the last > week. Week 1 is the first week where four or more days fall > within the > new year (or, synonymously, week 01 is: the first week of the > year that > contains a Thursday; or, the week that has 4 January in > it). When > three of fewer days of the first calendar week of the new > year fall > within that year, then the ISO 8601 week-based system counts > those days > as part of week 53 of the preceding year. For example, 1 > January 2010 > is a Friday, meaning that just three days of that calendar > week fall in > 2010. Thus, the ISO 8601 week-based system considers these > days to be > part of week 53 (%V) of the year 2009 (%G) ; week 01 of ISO > 8601 year > 2010 starts on Monday, 4 January 2010. >=20 > Perhaps you are looking for the ISO week date %V? And if just doing > calculations I suggest using UTC. >=20 > $ date -u -d 'Dec 31 2012 12:00 +0000' +%V > 01 >=20 > The 'ncal' program provides a useful but unusual way to display the > ISO week numbers: >=20 > $ ncal -A 1 -w 12 2012 > December 2012 January 2013 > Su 2 9 16 23 30 6 13 20 27 > Mo 3 10 17 24 31 7 14 21 28 > Tu 4 11 18 25 1 8 15 22 29 > We 5 12 19 26 2 9 16 23 30 > Th 6 13 20 27 3 10 17 24 31 > Fr 7 14 21 28 4 11 18 25 > Sa 1 8 15 22 29 5 12 19 26 > 48 49 50 51 52 1 1 2 3 4 5 >=20 > You should also read the FAQ: >=20 > http://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-work= ing-right_002e >=20 > No one is ever happy with week numbers. >=20 > Bob >=20 Bob, many thanks for in depth explanation! Please close this is not a bug. --=20 Tomas Daba=C5=A1inskas | Engineering Content Services | Red Hat Asia Pacifi= c =E2=98=BA: tomas | =E2=98=8E: +61(0)7 3514 8204 | =E2=9C= =89: tomas@redhat.com From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 07 19:09:23 2013 Received: (at control) by debbugs.gnu.org; 8 Jan 2013 00:09:23 +0000 Received: from localhost ([127.0.0.1]:55760 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TsMkq-0005NB-Ta for submit@debbugs.gnu.org; Mon, 07 Jan 2013 19:09:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20401) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TsMkn-0005Mw-7r for control@debbugs.gnu.org; Mon, 07 Jan 2013 19:09:19 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r08099Un028001 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 7 Jan 2013 19:09:10 -0500 Received: from [10.36.116.37] (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r080971C006060 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Jan 2013 19:09:09 -0500 Message-ID: <50EB63A2.5070901@draigBrady.com> Date: Tue, 08 Jan 2013 00:09:06 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: control@debbugs.gnu.org Subject: Re: bug#13372: bug in date with last week calculation References: <1429027069.88842.1357516139363.JavaMail.root@redhat.com> <1169310300.538379.1357601702659.JavaMail.root@redhat.com> In-Reply-To: <1169310300.538379.1357601702659.JavaMail.root@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: control Cc: Bob Proulx 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.0 (-----) tag 13372 notabug close 13372