GNU bug report logs - #6897
date -d '1991-04-14 +1 day' fails

Previous Next

Package: coreutils;

Reported by: 李嘉鹏 <lijpbasin <at> 126.com>

Date: Sun, 22 Aug 2010 19:33:02 UTC

Severity: normal

Done: Bob Proulx <bob <at> proulx.com>

Bug is archived. No further changes may be made.

Full log


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

From: Bob Proulx <bob <at> proulx.com>
To: 李嘉鹏 <lijpbasin <at> 126.com>
Cc: 6897-done <at> debbugs.gnu.org
Subject: Re: bug#6897: date -d '1991-04-14 +1 day' fails
Date: Mon, 23 Aug 2010 02:48:43 -0600
Bob Proulx wrote:
> 李嘉鹏 wrote:
> > I used some script(At the end of the letter) to get a series of
> > date. but the script always fails at the date 1991-04-14. so I
> > tested the single command
> >     date -d '1991-04-14 +1 day'
> > It would also fail with a error message
> >     date: invalid date `1991-04-14 +1 day'
> > displayed.
> 
> Thank you for the bug report.  However I am unable to reproduce it.
> Therefore I conclude that the problem must be related to your
> timezone.  Because you are taking dates a midnight I am guessing that
> there is very likely a daylight savings time issue there.  (Was
> Daylight Savings Time active then?)  Instead, try looking at dates at
> noon.
> 
>   date -d '1991-04-14 12:00 +1 day'

Using Asia/Chongqing timezone shows that DST was active at that time.

  $ zdump -v Asia/Chongqing | grep 1991
  Asia/Chongqing  Sat Apr 13 15:59:59 1991 UTC = Sat Apr 13 23:59:59 1991 CST isdst=0 gmtoff=28800
  Asia/Chongqing  Sat Apr 13 16:00:00 1991 UTC = Sun Apr 14 01:00:00 1991 CDT isdst=1 gmtoff=32400
  Asia/Chongqing  Sat Sep 14 14:59:59 1991 UTC = Sat Sep 14 23:59:59 1991 CDT isdst=1 gmtoff=32400
  Asia/Chongqing  Sat Sep 14 15:00:00 1991 UTC = Sat Sep 14 23:00:00 1991 CST isdst=0 gmtoff=28800

There was no 1991-04-14 00:00:00 since the time progressed to Apr 14
01:00:00 with the next clock tick.  Because 1991-04-14 00:00:00 does
not exist 'date' returns an invalid date error for it.

Using the time at noon would avoid these problems.  Also using time in
UTC avoids all daylight savings time issues.

Bob




This bug report was last modified 14 years and 275 days ago.

Previous Next


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