When running the following command with GNU date :
date -d "20145-01-23"
date: invalid date `20145-01-23'
For numeric months, the ISO 8601 format ‘year-month-day’ is allowed, where year is any positive number [...]
This works for me, using GNU coreutils 8.24:
$ date -d "20145-01-23" Sat Jan 23 00:00:00 PST 20145
I'm not certain of this explanation (UPDATE: looks like my guess was correct), but my guess is that you're on a system with a 32-bit
time_t rather than 64 bits. With 32 bits, the only representable dates are from Fri 1901-12-13 20:45:52 UTC (231 seconds before the epoch) to Tue 2038-01-19 03:14:07 UTC (231-1 seconds after the epoch).
If this is the case, then this command should succeed:
$ date -d 2037-01-01 Thu Jan 1 00:00:00 PST 2037
and this one should fail:
$ date -d 2039-01-01 date: invalid date ‘2039-01-01’
(I've reconstructed what the result should look like for that last command. The output of the first will vary slightly depending on your time zone.)
how to obtain the same behavior than BSD date, which accepts this as a valid date ?
Are you saying you want BSD date to reject it? If so (more speculation), either run a 32-bit version of BSD, or test whether the requested time is outside the 32-bit range of timestamps.