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

Unexpected results with min/max #2

Open
mattBrzezinski opened this issue Mar 10, 2021 · 0 comments
Open

Unexpected results with min/max #2

mattBrzezinski opened this issue Mar 10, 2021 · 0 comments

Comments

@mattBrzezinski
Copy link
Member

min and max between a ZonedDateTime and a LaxZonedDateTime works admirably well in almost all situations:

julia> dt = ZonedDateTime(2016, 11, 6, winnipeg)
2016-11-06T00:00:00-05:00

julia> lzdt = LaxZonedDateTime(DateTime(2016, 11, 6, 1), winnipeg)
2016-11-06T01:00:00-AMB

julia> min(lzdt, dt)
2016-11-06T00:00:00-05:00

julia> max(dt, lzdt)
2016-11-06T01:00:00-AMB

julia> dt = ZonedDateTime(2016, 11, 6, 2, winnipeg)
2016-11-06T02:00:00-06:00

julia> min(lzdt, dt)
2016-11-06T01:00:00-AMB

julia> max(dt, lzdt)
2016-11-06T02:00:00-06:00

That's great! However...

julia> dt = ZonedDateTime(2016, 11, 6, 1, 30, winnipeg, 2)
2016-11-06T01:30:00-06:00

julia> lzdt = LaxZonedDateTime(DateTime(2016, 11, 6, 1), winnipeg)
2016-11-06T01:00:00-AMB

julia> min(dt, lzdt)
2016-11-06T01:00:00-AMB

julia> max(dt, lzdt)
2016-11-06T01:30:00-06:00

When the LaxZonedDateTime is ambiguous, it appears that min(dt::ZonedDateTime, lzdt::LaxZonedDateTime) will always return lzdt (provided dt is within the same period of potential ambiguity) and max will always return dt, even in the above case where it is impossible for lzdt to be less than dt.

Honestly I'm not sure this worth fixing. But it is certainly worth being aware of.

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

1 participant