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

To reply to this bug, email your comments to 37961 AT debbugs.gnu.org.

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#37961; Package coreutils. (Mon, 28 Oct 2019 14:34:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to "zhangzhimin <at> mail.iap.ac.cn" <zhangzhimin <at> mail.iap.ac.cn>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 28 Oct 2019 14:34:03 GMT) Full text and rfc822 format available.

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

From: "zhangzhimin <at> mail.iap.ac.cn" <zhangzhimin <at> mail.iap.ac.cn>
To: bug-coreutils <bug-coreutils <at> gnu.org>
Subject: Bug report of date commond
Date: Mon, 28 Oct 2019 15:34:38 +0800
[Message part 1 (text/plain, inline)]
Mr. maintainers:
        Hello! I am very glad to write this email to report my problem.
        When I am running commond on my server: 

~>date  -d "1940-06-01" +"%Y-%m-%d"
date: invalid date ‘1940-06-01’

but the other commond works right:
sense3:~>date  -d '1939-06-01' +"%Y-%m-%d"
1939-06-01
sense3:~>date  -d '1940-06-02' +"%Y-%m-%d"
1940-06-02
sense3:~>date  -d '1940-05-31' +"%Y-%m-%d"
1940-05-31
sense3:~>date  -d '1940-07-02' +"%Y-%m-%d"
1940-07-02
sense3:~>date  -d '1940-07-01' +"%Y-%m-%d"
1940-07-01
sense3:~>date  -d '1940-05-01' +"%Y-%m-%d"
1940-05-01


    my server's version and date version is:
~>uname -a
Linux zenglab 3.10.0-957.12.1.el7.x86_64 #1 SMP Mon Apr 29 14:59:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
~>date --version
date (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://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.

    This error makes my program woking wrong. Hope for your reply.

    Thank you!






 张志敏 技术工程师                                                            
单位:中国科学院大气物理研究所 大气科学和地球流体力学数值模拟国家重点实验室(LASG)地址:中国北京市朝阳区德胜门外祁家豁子华严里40#,北京,100029          邮箱:zhangzhimin <at> mail.iap.ac.cn
电话:13391835740
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#37961; Package coreutils. (Mon, 28 Oct 2019 18:53:02 GMT) Full text and rfc822 format available.

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.