GNU bug report logs -
#61528
date doesn't parse negative years
Previous Next
Full log
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 2 years and 127 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.