From unknown Tue Jun 24 22:34:18 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#12772 <12772@debbugs.gnu.org> To: bug#12772 <12772@debbugs.gnu.org> Subject: Status: date : Bug in handling human readable dates Reply-To: bug#12772 <12772@debbugs.gnu.org> Date: Wed, 25 Jun 2025 05:34:18 +0000 retitle 12772 date : Bug in handling human readable dates reassign 12772 coreutils submitter 12772 ga@alexandersfeld.de severity 12772 normal tag 12772 notabug moreinfo thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 31 11:58:53 2012 Received: (at submit) by debbugs.gnu.org; 31 Oct 2012 15:58:53 +0000 Received: from localhost ([127.0.0.1]:41670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTagu-0005Fq-Ka for submit@debbugs.gnu.org; Wed, 31 Oct 2012 11:58:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52200) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTVUF-00054y-5O for submit@debbugs.gnu.org; Wed, 31 Oct 2012 06:25:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTVRd-0008MH-0E for submit@debbugs.gnu.org; Wed, 31 Oct 2012 06:22:50 -0400 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 autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:49055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTVRc-0008MD-TZ for submit@debbugs.gnu.org; Wed, 31 Oct 2012 06:22:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTVRT-0002hn-Ic for bug-coreutils@gnu.org; Wed, 31 Oct 2012 06:22:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTVRL-0008I7-OJ for bug-coreutils@gnu.org; Wed, 31 Oct 2012 06:22:35 -0400 Received: from gamma.vrg.de ([62.157.185.29]:39724) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTVRL-0008Hj-F3 for bug-coreutils@gnu.org; Wed, 31 Oct 2012 06:22:27 -0400 Received: from proxyint.vrg-ol.de (localsmtp.vrg-ol.de [10.4.15.222]) by gamma.vrg.de (8.14.3/8.14.3/Debian-5) with ESMTP id q9VA0P5A009409 for ; Wed, 31 Oct 2012 11:00:25 +0100 Received: from databox.vrg.de (proxyint.vrg-ol.de [10.4.15.222]) by proxyint.vrg-ol.de (Postfix) with ESMTP id D442C1E374F for ; Wed, 31 Oct 2012 11:00:24 +0100 (CET) Received: from databox.vrg.de (databox.vrg.de [127.0.0.1]) by databox.vrg.de (8.14.3/8.14.3/Debian-9.4) with ESMTP id q9VA0NYp001866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 31 Oct 2012 11:00:23 +0100 Received: (from root@localhost) by databox.vrg.de (8.14.3/8.14.3/Submit) id q9VA0MgE001865 for bug-coreutils@gnu.org; Wed, 31 Oct 2012 11:00:22 +0100 Date: Wed, 31 Oct 2012 11:00:22 +0100 From: Guido Ackermann To: bug-coreutils@gnu.org Subject: date : Bug in handling human readable dates Message-ID: <20121031100022.GA20927@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 31 Oct 2012 11:58:51 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: ga@alexandersfeld.de 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 (----) Hello, today i discovered a bug in the programm "date" handling human readable timeformats. The bug: # date --version date (GNU coreutils) 8.5 # export LC_ALL="C" ;date Wed Oct 31 10:57:06 CET 2012 # export LC_ALL="C" ;date -d"last month" Mon Oct 1 11:57:23 CEST 2012 # export LC_ALL="C" ;date -d"next month" Sat Dec 1 10:57:35 CET 2012 While aktual monthh is still Oct, previous month is shown as Oct too, and next month is shown as Dec. Correctly "last month" should be Sep. "next month" should be Nov. regards, Guido Ackermann From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 31 15:44:50 2012 Received: (at 12772) by debbugs.gnu.org; 31 Oct 2012 19:44:50 +0000 Received: from localhost ([127.0.0.1]:41942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTeDa-0002sF-7l for submit@debbugs.gnu.org; Wed, 31 Oct 2012 15:44:50 -0400 Received: from joseki.proulx.com ([216.17.153.58]:40800) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTeDY-0002s3-54; Wed, 31 Oct 2012 15:44:49 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 8F321211D5; Wed, 31 Oct 2012 13:42:08 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 6477B2DCD7; Wed, 31 Oct 2012 13:42:08 -0600 (MDT) Date: Wed, 31 Oct 2012 13:42:08 -0600 From: Bob Proulx To: Guido Ackermann Subject: Re: bug#12772: date : Bug in handling human readable dates Message-ID: <20121031194208.GA8966@hysteria.proulx.com> References: <20121031100022.GA20927@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121031100022.GA20927@localhost.localdomain> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 12772 Cc: 12772@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: 0.1 (/) tag 12772 + notabug moreinfo thanks Guido Ackermann wrote: > today i discovered a bug in the programm "date" handling human > readable timeformats. Thank you for the bug report. And also thank you very much for including the version you are using. However you are tripping over a common misconception about date. > # export LC_ALL="C" ;date > Wed Oct 31 10:57:06 CET 2012 In addition to LC_ALL please tell us what timezone you are using. The timezone string is ambiguous and CET may not be unique. Better is to use the -R format to get a standard unambiguous format. Best is to use UTC which avoids all of those issues. You can do both on the command without 'export'. Using 'env' is the canonical method across all shells. For example: $ env LC_ALL=C TZ=Europe/Berlin date -R > # export LC_ALL="C" ;date -d"last month" > Mon Oct 1 11:57:23 CEST 2012 $ env LC_ALL=C TZ=Europe/Berlin date -R -d "last month" Mon, 01 Oct 2012 21:36:34 +0200 > # export LC_ALL="C" ;date -d"next month" > Sat Dec 1 10:57:35 CET 2012 $ env LC_ALL=C TZ=Europe/Berlin date -R -d "next month" Sat, 01 Dec 2012 20:35:55 +0100 > While aktual monthh is still Oct, previous month is shown as Oct > too, and next month is shown as Dec. > Correctly "last month" should be Sep. "next month" should be Nov. Yes. However this behavior is documented. See the manual for the full documentation. Here are some sections from it: The unit of time displacement may be selected by the string `year' or `month' for moving by whole years or months. These are fuzzy units, as years and months are not all of equal duration. More precise units are `fortnight' which is worth 14 days, `week' worth 7 days, `day' worth 24 hours, `hour' worth 60 minutes, `minute' or `min' worth 60 seconds, and `second' or `sec' worth one second. An `s' suffix on these units is accepted and ignored. ... The fuzz in units can cause problems with relative items. For example, `2003-07-31 -1 month' might evaluate to 2003-07-01, because 2003-06-31 is an invalid date. To determine the previous month more reliably, you can ask for the month before the 15th of the current month. For example: $ date -R Thu, 31 Jul 2003 13:02:39 -0700 $ date --date='-1 month' +'Last month was %B?' Last month was July? $ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B!' Last month was June! Also, take care when manipulating dates around clock changes such as daylight saving leaps. In a few cases these have added or subtracted as much as 24 hours from the clock, so it is often wise to adopt universal time by setting the `TZ' environment variable to `UTC0' before embarking on calendrical calculations. Please also see the FAQ where this issue is discussed at some length. http://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-working-right_002e Does that sufficiently answer your issue? Bob From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 31 15:54:25 2012 Received: (at 12772-done) by debbugs.gnu.org; 31 Oct 2012 19:54:25 +0000 Received: from localhost ([127.0.0.1]:41951 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTeMq-00036S-RT for submit@debbugs.gnu.org; Wed, 31 Oct 2012 15:54:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8533) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTeMm-00036I-BR for 12772-done@debbugs.gnu.org; Wed, 31 Oct 2012 15:54:22 -0400 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 q9VJpW4O012131 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 31 Oct 2012 15:51:32 -0400 Received: from [10.3.113.77] (ovpn-113-77.phx2.redhat.com [10.3.113.77]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9VJpV3E016568; Wed, 31 Oct 2012 15:51:32 -0400 Message-ID: <50918143.9000002@redhat.com> Date: Wed, 31 Oct 2012 13:51:31 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 MIME-Version: 1.0 To: ga@alexandersfeld.de Subject: Re: bug#12772: date : Bug in handling human readable dates References: <20121031100022.GA20927@localhost.localdomain> In-Reply-To: <20121031100022.GA20927@localhost.localdomain> X-Enigmail-Version: 1.4.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig276669C6274A0D6DAB8CF1ED" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Spam-Score: -4.9 (----) X-Debbugs-Envelope-To: 12772-done Cc: 12772-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: -4.9 (----) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig276669C6274A0D6DAB8CF1ED Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable tag 12772 notabug thanks On 10/31/2012 04:00 AM, Guido Ackermann wrote: > Hello, > today i discovered a bug in the programm "date" handling human readable= timeformats. > The bug: >=20 > # date --version > date (GNU coreutils) 8.5 >=20 > # export LC_ALL=3D"C" ;date > Wed Oct 31 10:57:06 CET 2012 > # export LC_ALL=3D"C" ;date -d"last month" > Mon Oct 1 11:57:23 CEST 2012 > # export LC_ALL=3D"C" ;date -d"next month" > Sat Dec 1 10:57:35 CET 2012 >=20 > While aktual monthh is still Oct, previous month is shown as Oct too, a= nd next month is shown as Dec. > Correctly "last month" should be Sep. "next month" should be Nov.=20 Thanks for the report. However, this is the result of daylight savings impacting the calculations. "last month" and "next month" translate to a fixed number of 24-hour jumps, but since you are in a month with a 25-hour day, you still end up in October when going backwards, and skip over the 30 days of November when going forwards. This is a FAQ: https://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-worki= ng-right_002e There, we give suggestions on how to avoid the ambiguities, such as by starting at noon rather than midnight when jumping by days, or using the 15th instead of the first or last of a month when jumping by months, in order to guarantee that the result lands in the desired granularity in spite of the non-uniformity caused by daylight savings or changing numbers of days per month. The FAQ also suggests using UTC instead of local timezone to avoid daylight savings issues. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig276669C6274A0D6DAB8CF1ED 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.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQkYFDAAoJEKeha0olJ0NqqEwIAKKcBo5UGFMxZ+h/CtkVQVhp EUPbopakSJIWIhfbpXrvw9LZ0H9bHW1/5rQOzqowkkfDKfFmRUyPOFKCy5HUsoWw h8hboNjW+iDqNJFgExwOJ2+Ixvr3RjXzTHJ0qiagFQ0UHaFNowut/UUfAsx1Xur3 h4YkV7X0S188sPcHxo6on5/7qo4humPu5Nxxk9vGlUINeR2uNXVjo64+hQyZaLMa QQ2tBvqPF3KgL44OL3RJ+yKbiEL9NYaWIm3Wa+by0lV2+vRJvLZqSZy96UhKjWSh BzmTC8X6RR+FD0nKCEz31FkENBF2udPd4QE/1+Uxfe1wy8QWlI1tQCXtZwfrSAc= =gjTs -----END PGP SIGNATURE----- --------------enig276669C6274A0D6DAB8CF1ED-- From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 01 01:37:37 2012 Received: (at 12772) by debbugs.gnu.org; 1 Nov 2012 05:37:37 +0000 Received: from localhost ([127.0.0.1]:42304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTnTD-00006i-Qp for submit@debbugs.gnu.org; Thu, 01 Nov 2012 01:37:37 -0400 Received: from ipmail04.adl6.internode.on.net ([150.101.137.141]:30264) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTkEr-0003nO-EE for 12772@debbugs.gnu.org; Wed, 31 Oct 2012 22:10:37 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvwEAMXYkVB20IoR/2dsb2JhbABEw2GBCYJfHD40JhgNiDyZaqFRjw+CQ2EDlXUBkEKDAQ Received: from ppp118-208-138-17.lns20.bne1.internode.on.net (HELO falcon.house.au) ([118.208.138.17]) by ipmail04.adl6.internode.on.net with ESMTP; 01 Nov 2012 12:37:50 +1030 Received: by falcon.house.au (Postfix, from userid 1002) id B956925710; Thu, 1 Nov 2012 12:07:47 +1000 (EST) Date: Thu, 1 Nov 2012 12:07:47 +1000 From: Nemo Maelstrom Thorx To: 12772@debbugs.gnu.org Subject: Re: bug#12772: date : Bug in handling human readable dates Message-ID: <20121101020747.GA16467@nemo.house.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Organization: Thorx Enterprises X-URL: http://www.thorx.net/ X-Disclaimer: Use of advanced messaging technology does not imply an endorsement of western industrial civilisation. X-Face: "J&zZ`5dpxp8"}ryn|Tqw_jjS{ZjVDDT`V]M2Cfn 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 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Coincidentally, I found this bug just today also, and whilst I acknowledge the workarounds if the only thing you need is the month, sometimes you need the relative position within the month also. I would suggest that the end of march's -1month would more intuitively map to the end of february, repeated. ie, "lock" the month in, and adjust the "least significant" part - the day. [...] Content analysis details: (1.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [150.101.137.141 listed in list.dnswl.org] -0.0 BAYES_40 BODY: Bayes spam probability is 20 to 40% [score: 0.3899] 1.5 FAKE_REPLY_C FAKE_REPLY_C Coincidentally, I found this bug just today also, and whilst I acknowledge the workarounds if the only thing you need is the month, sometimes you need the relative position within the month also. I would suggest that the end of march's -1month would more intuitively map to the end of february, repeated. ie, "lock" the month in, and adjust the "least significant" part - the day. Same sort of unintuitive results can occur with requesting +1 month, or even +/-1year from February 29. I also thought it might be illuminating to see how other systems handle this ambiguity. mysql> SELECT DATE_SUB('2012-03-31', INTERVAL 1 MONTH); +------------------------------------------+ | DATE_SUB('2012-03-31', INTERVAL 1 MONTH) | +------------------------------------------+ | 2012-02-29 | +------------------------------------------+ 1 row in set (0.00 sec) Colleagues inform me that postgresql behaves this way also, alongside python's mx.DateTime library (and ms-sql too). Conversely, sqlite, php behave like 'date' :) .../Nemo -- ----------------------------------------- ----------------------------- earth native -- ----------------------------------------- ----------------------------- earth native From unknown Tue Jun 24 22:34:18 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 29 Nov 2012 12:24:03 +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