Skip to content

Unexpected results with min/max #2

@mattBrzezinski

Description

@mattBrzezinski

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions