bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#61528: date doesn't parse negative years


From: Richard Neill
Subject: bug#61528: date doesn't parse negative years
Date: Wed, 15 Feb 2023 04:31:45 +0000
User-agent: Roundcube Webmail/1.4.13

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]