emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#50115: closed (date command arithmetic involving the epoch produces


From: GNU bug Tracking System
Subject: bug#50115: closed (date command arithmetic involving the epoch produces "invalid date")
Date: Sat, 05 Feb 2022 21:56:01 +0000

Your message dated Sat, 5 Feb 2022 13:55:26 -0800
with message-id <c31c92f0-7ea6-15fa-8751-815d08ebcbfe@cs.ucla.edu>
and subject line Re: bug#50115: date command arithmetic involving the epoch 
produces "invalid date"
has caused the debbugs.gnu.org bug report #50115,
regarding date command arithmetic involving the epoch produces "invalid date"
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
50115: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=50115
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: date command arithmetic involving the epoch produces "invalid date" Date: Wed, 18 Aug 2021 20:43:01 -0500
Using `date --utc --date="..."` with a date specification that
decrements by years that should result in epoch=0
(1969-12-31T23:59:59+00:00) produces an "invalid date" error message.

The following commands should illustrate the problem:

Notice that the only difference between the starting dates is 1 second.
```sh
$ date -u -d "1970-12-31T23:59:59+00:00 - 1 year"
date: invalid date ‘1970-12-31T23:59:59+00:00 - 1 year’
$ date -u -d "1970-12-31T23:59:58+00:00 - 1 year"
Wed Dec 31 11:59:58 PM UTC 1969
```

The dates are only considered invalid if they fall on epoch=0:
```sh
$ date -u -d "1971-12-31T23:59:59+00:00 - 2 year"
date: invalid date ‘1971-12-31T23:59:59+00:00 - 2 year’
$ date -u -d "1972-12-31T23:59:59+00:00 - 3 year"
date: invalid date ‘1972-12-31T23:59:59+00:00 - 3 year’
```

Going the other direction seems to work:
```sh
$ date -u -d "1969-01-01T00:00:00+00:00 + 1 year"
Thu Jan  1 12:00:00 AM UTC 1970
```

It only seems to error when decrementing by years:
```sh
 date -u -d "1970-01-01T00:00:01+00:00 - 1 second"
Thu Jan  1 12:00:00 AM UTC 1970
```

It only seems to error when using --utc, because the following works
(my time zone is America/Chicago):
```sh
$ date -d "Wed Dec 31 06:00:00 PM CST 1970 - 1 year" +%s
0
```



--- End Message ---
--- Begin Message --- Subject: Re: bug#50115: date command arithmetic involving the epoch produces "invalid date" Date: Sat, 5 Feb 2022 13:55:26 -0800 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Thanks for the bug report. I installed the attached patches to Gnulib and to Coreutils, and the fix should be in the next Coreutils release.

Attachment: 0001-parse-datetime-allow-calculations-to-yield-1.patch
Description: Text Data

Attachment: 0001-build-update-gnulib-submodule-to-latest.patch
Description: Text Data

Attachment: 0002-date-test-against-bug-50115.patch
Description: Text Data


--- End Message ---

reply via email to

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