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: --date always results in invalid date #2685

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

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

BuriedInTheGround opened this issue Sep 15, 2021 · 4 comments
Labels

Comments

@BuriedInTheGround
Copy link

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
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants