coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

`date -d"@1690466034"` isn't supported

Open sylvestre opened this issue 1 year ago • 9 comments

with GNU:

$ LANG=C /usr/bin/date -d"@1690466034"
Thu Jul 27 15:53:54 CEST 2023

with our:

$ date -d"@1690466034"
date: invalid date '@1690466034'

sylvestre avatar Aug 20 '23 11:08 sylvestre

Just to point people in the right direction: this should probably be fixed in parse_datetime

tertsdiepraam avatar Aug 20 '23 14:08 tertsdiepraam

@sylvestre @tertsdiepraam I would like to work on this.

philolo1 avatar Aug 20 '23 23:08 philolo1

After some investigation, i think "@" is just the number of seconds and the GNU date uses parse-datetime https://github.com/coreutils/gnulib/blob/master/lib/parse-datetime.y#L597

philolo1 avatar Aug 21 '23 00:08 philolo1

@philolo1, I'm debugging here as well. The code uses parse_datetime::from_str(...) that doesn't parse "@1690466034", but parse_datetime::parse_datetime::from_str(...) does.

BFostek avatar Aug 21 '23 00:08 BFostek

@BFostek @tertsdiepraam @sylvestre If we use parse_datetime::parse_datetime::from_str we would not be able to parse relative time, i think we need to use both in this pr.

philolo1 avatar Aug 21 '23 01:08 philolo1

@BFostek @tertsdiepraam @sylvestre https://github.com/uutils/coreutils/pull/5181

I just did a pull request. I think there are some other improvements that could be made, but i would prefer to do it in a different pr. For example my ubunto gnu also support negative unix timestamps like "@-2". Would it be appropiate to create a new issue for this?

philolo1 avatar Aug 21 '23 02:08 philolo1

It is not an invalid date already, but it is not the same yet

$ LANG=C /usr/bin/date -d"@1690466034"
Thu Jul 27 13:53:54 UTC 2023
$ coreutils date -d"@1690466034"
Thu Jul 27 13:53:54 2023

apatrushev avatar Mar 28 '24 21:03 apatrushev

Currently date until doesn't print Time zone abbreviations. It should be fixed once this PR is merged https://github.com/uutils/coreutils/pull/5164.

KrishnaNagam avatar Apr 21 '24 19:04 KrishnaNagam

@sylvestre I believe this issue has been fixed (probably by the work done by @philolo1 on parse_datetime?):

kov@jabuticaba ~/P/c/s/u/date (main)> LC_TIME=C /usr/bin/date -d"@-1690466034"
Wed Jun  7 07:06:06 -03 1916
kov@jabuticaba ~/P/c/s/u/date (main)> LC_TIME=C cargo run -- -d"@-1690466034"
<snip>
Wed Jun  7 07:06:06 1916

kov avatar Jul 20 '24 14:07 kov