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: fails to parse +N and -N in absolute time string as a time zone #7065

Open
jfinkels opened this issue Jan 3, 2025 · 3 comments
Open
Labels

Comments

@jfinkels
Copy link
Collaborator

jfinkels commented Jan 3, 2025

Environment: Ubuntu 20.04, uutils main branch (git commit 88cdf16), GNU coreutils v8.30

Steps to reproduce:

TZ=UTC0 date -d '1997-01-19 08:17:48 +0'

What happens now: uutils date terminates with an error because it doesn't understand the +0 time zone:

date: invalid date '1997-01-19 08:17:48 +0'

If you remove the +0, then uutils date does successfully parse the date string.

What I expected to happen: GNU date successfully interprets the +0 as a time zone:

Sun 19 Jan 1997 08:17:48 AM UTC

Notes: this is causing a test failure in GNU test file tests/date/date.pl.

@Felle33
Copy link
Contributor

Felle33 commented Jan 9, 2025

Making some tests, the code can sucessfully parse the strings TZ=UTC0 date -d '1997-01-19 08:17:48 +0000' and TZ=UTC0 date -d '1997-01-19 08:17:48 +00:00'.
We could try to parse the timezone and then pass the right argument to the function parse_datetime::parse_datetime_at_date(...).
What do you think?

@jfinkels
Copy link
Collaborator Author

jfinkels commented Jan 9, 2025

Maybe the parse_datetime_at_date function in https://github.com/uutils/parse_datetime just needs to be updated to understand the string "+0", etc.?

@Felle33
Copy link
Contributor

Felle33 commented Jan 9, 2025

Inspecting the code, I see that they try to parse also the timezone, but since %z accepts only 4 digits (i.e +0000) or 4 digits separated by : (i.e +00:00), the function returns an error

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

2 participants