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

What is datediff's expected behavior w.r.t. Daylight Saving Time changes? #129

Closed
mattdm opened this issue Aug 7, 2021 · 3 comments
Closed

Comments

@mattdm
Copy link

mattdm commented Aug 7, 2021

I grew up in Indiana, long enough ago that we didn't have to deal with this nonsense. But alas, madness seems to be almost universal. So:

$ date -d "2021-03-14 1:59"
Sun Mar 14 01:59:00 AM EST 2021

$ date -d "2021-03-14 2:00"
date: invalid date ‘2021-03-14 2:00’

$ date -d "2021-03-14 3:00"
Sun Mar 14 03:00:00 AM EDT 2021

... but:

$ datediff "2021-03-14 1:59" "2021-03-14 3:00"
3660s

I guess an alternate way of asking this is: what timezone does datediff assume when one isn't explicitly given? My naïve expectation was that it'd follow the timezone set in my environment, including handling DST transitions.

@hroptatyr
Copy link
Owner

Hi Matt,
the timezone that's used by default is UTC. And you're right you'd have to specify it explicitly

$ datediff --from-zone America/New_York "2021-03-14 1:59" "2021-03-14 3:00"
60s

The opposite is more interesting

$ datediff --from-zone America/New_York "2021-11-07 1:59" "2021-11-07 2:00"
3660s

and there is no way (as per ISO 8601 and hence dateutils) to specify which one of the two 2 o'clocks you're referring to.

@mattdm
Copy link
Author

mattdm commented Aug 8, 2021

Thanks! I guess probably the concrete thing here is that it'd be nice to have this information (UTC) in the man page, and perhaps also the example.

hroptatyr added a commit that referenced this issue Aug 10, 2021
* bug/129:
  doc, mention special zones (UTC, TAI, GPS)
  hygiene, update leap-seconds.list for upcoming release
  doc, add paragraph about default zone parameter, fixes #129
@hroptatyr
Copy link
Owner

I followed your suggestion and mentioned the special treatment of some zones, and UTC in particular. I'm ready to roll a new release, if not by this week then by the next.

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

No branches or pull requests

2 participants