GNU bug report logs -
#50115
date command arithmetic involving the epoch produces "invalid date"
Previous Next
Full log
Message #8 received at 50115 <at> debbugs.gnu.org (full text, mbox):
On line 2160 in `./gnulib/lib/parse-datetime.y`, there's this:
```c
if (Start == (time_t) -1)
{
if (debugging (&pc))
dbg_printf (_("error: adding relative date resulted "
"in an invalid date: '%s'\n"),
debug_strfdatetime (&tm, &pc, dbg_tm,
sizeof dbg_tm));
goto fail;
}
```
This seems to indicate that, if the parsed value is -1, it's
considered an invalid date, but isn't -1 a valid date in epoch
seconds?
Passing --debug to the date shows the correct result, but claims it's invalid:
```sh
$ ./src/date --debug -u -d "1970-12-31T23:59:59+00:00 - 1 year"
date: parsed datetime part: (Y-M-D) 1970-12-31 23:59:59 UTC+00
date: parsed relative part: -1 year(s)
date: input timezone: parsed date/time string (+00)
date: using specified time as starting value: '23:59:59'
date: starting date/time: '(Y-M-D) 1970-12-31 23:59:59 TZ=+00'
date: warning: when adding relative months/years, it is recommended to
specify the 15th of the months
date: error: adding relative date resulted in an invalid date:
'(Y-M-D) 1969-12-31 23:59:59 TZ=+00'
./src/date: invalid date ‘1970-12-31T23:59:59+00:00 - 1 year’
```
This bug report was last modified 3 years and 165 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.