GNU bug report logs - #48085
date -d greater than 23 years ago gives error invalid date

Previous Next

Package: coreutils;

Reported by: Mark Krenz <mark <at> slugbug.org>

Date: Wed, 28 Apr 2021 20:31:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48085 in the body.
You can then email your comments to 48085 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#48085; Package coreutils. (Wed, 28 Apr 2021 20:31:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mark Krenz <mark <at> slugbug.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 28 Apr 2021 20:31:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mark Krenz <mark <at> slugbug.org>
To: bug-coreutils <at> gnu.org
Subject: date -d greater than 23 years ago gives error invalid date
Date: Wed, 28 Apr 2021 20:24:50 +0000
 
I ran the following expecting it to provide me with the date 35 years
ago

  date -d "now - 35 years"

Instead I received the error:

  date: invalid date ‘now - 35 years’

Testing it further I found that the break point is at 24 years:

$ date --version
date (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
$ date -d "now - 23 years"
Tue Apr 28 03:20:37 PM EST 1998
$ date -d "now - 24 years"
date: invalid date ‘now - 24 years’
$

I compiled from the latest coreutils source and found it to have
the same issue:

$ cd coreutils/src/
$ ./date --version
date (GNU coreutils) 8.32.143-62a7c
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
$ date "now - 23 years"
date: invalid date ‘now - 23 years’
$ date -d "now - 23 years"
Tue Apr 28 03:21:09 PM EST 1998
$ date -d "now - 24 years"
date: invalid date ‘now - 24 years’
$


I found that this did work on a system running coreutils 8.23 so
something seems to have broken since then. These are all Linux systems
that I've tried this on. The system I tested on was a fresh Ubuntu 21.04
VM.

Linux ubuntu2104 5.11.0-16-generic #17-Ubuntu SMP Wed Apr 14 20:12:43 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Thanks,
Mark
 




Information forwarded to bug-coreutils <at> gnu.org:
bug#48085; Package coreutils. (Wed, 28 Apr 2021 21:15:02 GMT) Full text and rfc822 format available.

Message #8 received at 48085 <at> debbugs.gnu.org (full text, mbox):

From: Mark Krenz <mark <at> slugbug.org>
To: 48085 <at> debbugs.gnu.org
Subject: Re: date -d greater than 23 years ago gives error invalid date
Date: Wed, 28 Apr 2021 21:14:33 +0000
Further investigating this problem it appears that at least today it
doesn't like going back past September 26th, 1997. But only when the
time delta is specified in years months or days.  You can go back
further if it's specified in total amounts of hours minutes or seconds.


$ date -d "now - 283 months"
Sun 28 Sep 1997 03:42:05 PM EST
$ date -d "now - 284 months"
date: invalid date ‘now - 284 months’

$ date -d "now - 283 months - 2 days"
Fri 26 Sep 1997 03:42:31 PM EST
$ date -d "now - 283 months - 3 days"
date: invalid date ‘now - 283 months - 3 days’

$ date -d "now - 8615 days"
Fri Sep 26 03:52:30 PM EST 1997
$ date -d "now - 8616 days"
date: invalid date ‘now - 8616 days’


$ date -d "now - 206804 hours"
Wed Sep 24 07:54:15 PM EST 1997

$ date -d "now - 12408240 minutes"
Wed Sep 24 08:03:50 PM EST 1997

$ date -d "now - 744590000 seconds"
Tue Sep 23 05:20:23 PM EST 1997


I don't see anything special about Sept 25th, 1997 in terms of it's
numeric value:

$ date -d "1997-09-25" +%s
875163600

Or the delta from now to then.

8615*86400 = 744336000

Very weird. I'll be curious to see what turns out to be the problem.  I
also found a system I'm running that has coreutils 8.30 and it did not
have the problem, so that narrows the gap a bit.

Mark




Information forwarded to bug-coreutils <at> gnu.org:
bug#48085; Package coreutils. (Wed, 28 Apr 2021 23:24:02 GMT) Full text and rfc822 format available.

Message #11 received at 48085 <at> debbugs.gnu.org (full text, mbox):

From: Mark Krenz <mark <at> slugbug.org>
To: 48085 <at> debbugs.gnu.org
Subject: Re: date -d greater than 23 years ago gives error invalid date
Date: Wed, 28 Apr 2021 23:23:24 +0000
  Well it seems that this might actually be related to timezone database
files. My timezone is America/Indianapolis but I noticed when I set the
timezone to America/New_York or UTC that this problem doesn't happen

$ TZ=America/Indianapolis date -d "now - 9001 days"
date: invalid date ‘now - 9001 days’
$ TZ=America/New_York date -d "now - 9001 days"
Thu 05 Sep 1996 07:05:55 PM EDT
$ TZ=UTC date -d "now - 9001 days"
Thu 05 Sep 1996 11:05:59 PM UTC
$ TZ=America/Metlakatla date -d "now - 9001 days"
date: invalid date ‘now - 9001 days’
$ 

I found that last one after trying a for loop in /usr/share/zoneinfo/America

So I'm not sure if this is a problem with coreutils or a change in the
zoneinfo database. Any ideas?

Mark




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Sat, 19 Feb 2022 23:58:02 GMT) Full text and rfc822 format available.

Notification sent to Mark Krenz <mark <at> slugbug.org>:
bug acknowledged by developer. (Sat, 19 Feb 2022 23:58:02 GMT) Full text and rfc822 format available.

Message #16 received at 48085-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Mark Krenz <mark <at> slugbug.org>
Cc: Gnulib bugs <bug-gnulib <at> gnu.org>, 48085-done <at> debbugs.gnu.org
Subject: Re: bug#48085: date -d greater than 23 years ago gives error invalid
 date
Date: Sat, 19 Feb 2022 15:57:16 -0800
[Message part 1 (text/plain, inline)]
On 4/28/21 16:23, Mark Krenz wrote:
> So I'm not sure if this is a problem with coreutils or a change in the
> zoneinfo database. Any ideas?

This appears to be a problem in the GNU C library, when its mktime 
deciphers the relatively unusual time zone history of Indiana.

I installed the attached patch into Gnulib and propagated it into 
Coreutils, so the issue should be fixed in the next release of GNU 
Coreutils. Eventually this patch should migrate from Gnulib to glibc so 
that other apps get the fix. Thanks for reporting the issue.
[0001-mktime-improve-heuristic-for-ca-1986-Indiana-DST.patch (text/x-patch, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 20 Mar 2022 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 36 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.