GNU bug report logs -
#61528
date doesn't parse negative years
Previous Next
To reply to this bug, email your comments to 61528 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#61528
; Package
coreutils
.
(Wed, 15 Feb 2023 08:12:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Richard Neill <rn214 <at> richardneill.org>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Wed, 15 Feb 2023 08:12:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello,
I noticed that date doesn't accept negative years, such as in the date:
-0001-01-02 (i.e. 2nd Jan 2 BC).
It's also somewhat puzzling that even through date will convert a
timestamp in that year to an output string, it won't parse that string
as valid (i.e. the last 2 lines below).
date +%Y-%m-%d -d '0001-01-02' -> 0001-01-02
date +%Y-%m-%d -d '0000-01-02' -> 0000-01-02
date +%Y-%m-%d -d '-0001-01-02' -> date: invalid date ‘-0001-01-02’
date +%Y-%m-%d -d @-62135510325 -> 0001-01-02
date +%Y-%m-%d -d @-62167132725 -> 0000-01-02
date +%Y-%m-%d -d @-62198668725 -> -001-01-02
date +%Y-%m-%d -d '-001-01-02' -> date: invalid date ‘-001-01-02’
My reading of ISO_8601 is that these are allowed in formats YYYY-MM-DD
where YYYY is a 4-6 digit number which may be positive, zero or
negative.
https://en.wikipedia.org/wiki/ISO_8601
Note that we should treat year 0 is also 1 BC, while -1 AD is 2 BC.
https://en.wikipedia.org/wiki/Year_zero
Thanks very much.
P.S. cal doesn't work with years 0 and below either.
This bug report was last modified 1 year and 286 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.