8000 date: `--date` always results in invalid date · Issue #2685 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

date: --date always results in invalid date #2685

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

Open
BuriedInTheGround opened this issue Sep 15, 2021 · 6 comments
Open

date: --date always results in invalid date #2685

BuriedInTheGround opened this issue Sep 15, 2021 · 6 comments

Comments

@BuriedInTheGround
Copy link
Contributor

As the title says, everything I tried to pass to the --date option results in invalid date.

$ date --version
date 0.0.7
$ date --date="Sun, 29 Feb 2004 16:21:42 -0800"
date: invalid date 'Sun, 29 Feb 2004 16:21:42 -0800'
$ date --date="@1631716521"
date: invalid date '@1631716521'

I am currently using the version 0.0.7 on NixOS 20.05.

Also, thanks for all your work!

@blyxxyz
Copy link
Contributor
blyxxyz commented Sep 15, 2021

It currently uses chrono's parsing, which is very strict, something like a subset of ISO-8601. These are accepted:

date --date="1970-01-01T00:00:00Z"
date --date="1970-01-01T00:00:00+01:00"

(It doesn't seem to do anything with the timezone afterwards, though.)

@BuriedInTheGround
Copy link
8000 Contributor Author

Ah, okay! Thanks for the info.
If this issue should be closed, you can do it or just let me know.

For others with a problem similar to mine: if you need to convert a unix epoch to retrieve the time between two moments, something like the following works good.

date --date="$(TZ=Etc/GMT printf '1970-01-01%(T%H:%M:%S)T+00:00\n' 12345)" -u +%H:%M

Specifically, I needed this to make this polybar script work.

@PedroHLC
Copy link

Any trick for having relative dates? (E.g: all the ones visible here: https://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html)

@tertsdiepraam
Copy link
Member

I can't find any relative date support in the code, but it's definitely something we should support, so feel free to open an issue for it!

LucasLarson added a commit to LucasLarson/uutils-coreutils that referenced this issue Mar 26, 2024
also treated in uutils#2685 and uutils#3463

Signed-off-by: Lucas Larson <LucasLarson@riseup.net>
Copy link
stale bot commented Apr 26, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 26, 2025
@cakebaker
Copy link
Contributor

From the two original examples one has been fixed in the meantime:

$ cargo run -q date --date="@1631716521"
Wed Sep 15 16:35:21 CEST 2021

The other example still fails:

$ cargo run -q date --date="Sun, 29 Feb 2004 16:21:42 -0800"
date: invalid date 'Sun, 29 Feb 2004 16:21:42 -0800'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0