GNU bug report logs - #37961
Bug report of date commond

Previous Next

Package: coreutils;

Reported by: "zhangzhimin <at> mail.iap.ac.cn" <zhangzhimin <at> mail.iap.ac.cn>

Date: Mon, 28 Oct 2019 14:34:03 UTC

Severity: normal

Full log


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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: "zhangzhimin <at> mail.iap.ac.cn" <zhangzhimin <at> mail.iap.ac.cn>,
 37961 <at> debbugs.gnu.org
Subject: Re: bug#37961: Bug report of date commond
Date: Mon, 28 Oct 2019 11:52:11 -0700
On 10/28/19 12:34 AM, zhangzhimin <at> mail.iap.ac.cn wrote:
> ~>date  -d "1940-06-01" +"%Y-%m-%d"
> date: invalid date ‘1940-06-01’

Presumably your TZ setting is Asia/Shanghai, as I see the symptoms as 
follows:

$ TZ=Asia/Shanghai date  -d "1940-06-01" +"%Y-%m-%d"
date: invalid date ‘1940-06-01’

This is because there is no instant of time 1940-06-01 00:00:00 in 
Shanghai, as the the clock ticked over from 1940-05-30 23:59:59 to 
1940-06-01 01:00:00 due to a daylight-saving time transition.

For this particular case, you'll have better luck with:

$ date -d "1940-06-01 12:00" +"%Y-%m-%d"

but this sort of approach does not work in general, because 12:00 does 
not always exist either. In other words, the 'date' command is not 
suited for calendrical arithmetic in general, only for time arithmetic.




This bug report was last modified 5 years and 321 days ago.

Previous Next


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