Yuri6037/time-tz

Add a fallible timezone conversion method

Opened this issue ยท 3 comments

The to_timezone method returns OffsetDateTime. Its implementation uses OffsetDateTime::to_offset which may panic if the resulting date is out of range. There is also the fallible OffsetDateTime::checked_to_offset, so it would be nice to provide a checked time zone conversion method using that, for people concerned about the Y10K problem ๐Ÿ˜

Since the extension trait is sealed, a new method can be added as a non-breaking change.

The to_timezone method returns OffsetDateTime. Its implementation uses OffsetDateTime::to_offset which may panic if the resulting date is out of range. There is also the fallible OffsetDateTime::checked_to_offset, so it would be nice to provide a checked time zone conversion method using that, for people concerned about the Y10K problem ๐Ÿ˜

I've updated the docs in master and added a new checked_to_timezone function.

Since the extension trait is sealed, a new method can be added as a non-breaking change.

Well since in master I've moved to_timezone to its own trait (not sealed) it's now a breaking change, fortunately it's only a breaking change from 1 pre-release to another (master is on 3.0.0-rc.2.0.0 now).

Well since in master I've moved to_timezone to its own trait (not sealed) it's now a breaking change

Ah! So now the unchecked method can be provided in the trait by default, implemented through the checked method.

Well since in master I've moved to_timezone to its own trait (not sealed) it's now a breaking change

Ah! So now the unchecked method can be provided in the trait by default, implemented through the checked method.

Not exactly because of the OutChecked type used to allow implementing checked_to_timezone on things like PosixTz or &str.