Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date -d"@1690466034" isn't supported #5177

Open
sylvestre opened this issue Aug 20, 2023 · 9 comments
Open

date -d"@1690466034" isn't supported #5177

sylvestre opened this issue Aug 20, 2023 · 9 comments
Labels

Comments

@sylvestre
Copy link
Contributor

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'
@cakebaker cakebaker changed the title date -d"@1690466034" isn't support date -d"@1690466034" isn't supported Aug 20, 2023
@tertsdiepraam
Copy link
Member

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

@philolo1
Copy link

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

@philolo1
Copy link

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

@BFostek
Copy link

BFostek commented Aug 21, 2023

@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.

@philolo1
Copy link

@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 added a commit to philolo1/coreutils that referenced this issue Aug 21, 2023
This resolved issue uutils#5177.

The PR adds a new enum  HumanDuration(Duration), HumanDateTime(DateTime<FixedOffset>) and uses  parse_datetime::parse_datetime::from_str  to support datetime if relative time cannot be parsed.

Furthermore tests are added for tests/by-util/test_date.rs.
@philolo1
Copy link

@BFostek @tertsdiepraam @sylvestre
#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 added a commit to philolo1/coreutils that referenced this issue Aug 21, 2023
This resolved issue uutils#5177.

The PR adds a new enum  HumanDuration(Duration), HumanDateTime(DateTime<FixedOffset>) and uses  parse_datetime::parse_datetime::from_str  to support datetime if relative time cannot be parsed.

Furthermore tests are added for tests/by-util/test_date.rs.
philolo1 added a commit to philolo1/coreutils that referenced this issue Sep 19, 2023
This resolved issue uutils#5177.

The PR adds a new enum  HumanDuration(Duration), HumanDateTime(DateTime<FixedOffset>) and uses  parse_datetime::parse_datetime::from_str  to support datetime if relative time cannot be parsed.

Furthermore tests are added for tests/by-util/test_date.rs.
philolo1 added a commit to philolo1/coreutils that referenced this issue Sep 19, 2023
This resolved issue uutils#5177.

The PR adds a new enum  HumanDuration(Duration), HumanDateTime(DateTime<FixedOffset>) and uses  parse_datetime::parse_datetime::from_str  to support datetime if relative time cannot be parsed.

Furthermore tests are added for tests/by-util/test_date.rs.
philolo1 added a commit to philolo1/coreutils that referenced this issue Sep 19, 2023
This resolved issue uutils#5177.

The PR adds a new enum  HumanDuration(Duration), HumanDateTime(DateTime<FixedOffset>) and uses  parse_datetime::parse_datetime::from_str  to support datetime if relative time cannot be parsed.

Furthermore tests are added for tests/by-util/test_date.rs.
sylvestre pushed a commit to philolo1/coreutils that referenced this issue Sep 23, 2023
This resolved issue uutils#5177.

The PR adds a new enum  HumanDuration(Duration), HumanDateTime(DateTime<FixedOffset>) and uses  parse_datetime::parse_datetime::from_str  to support datetime if relative time cannot be parsed.

Furthermore tests are added for tests/by-util/test_date.rs.
@apatrushev
Copy link
Contributor

apatrushev commented Mar 28, 2024

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

@KrishnaNagam
Copy link

Currently date until doesn't print Time zone abbreviations. It should be fixed once this PR is merged #5164.

@kov
Copy link

kov commented Jul 20, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

7 participants