Open pitdicker opened 5 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 91.83%. Comparing base (
f8cecbe
) to head (2a8af8b
). Report is 17 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I propose to add a
FromOffset
trait thatOffset
types can implement to convert from any genericOffset
. And to add aDateTime::to_timezone
method to conveniently convert aDateTime<Tz>
into another type.If we implement
FromOffset
in chrono-tz it we can do nice things such as converting fromFixedOffset
to aTz
time zone for a fixed offset, or eventually fromLocalOffset
(#1563) to aTz
with the same time zone if possible.
This all sounds kind of speculative and not as a current/near-future thing?
If so, I'd rather hold off on merging this now.
Alternatively stated: what do you envision to be the concrete near-term benefit for our users?
I hope to prove it useful soon. Fine to hold off for now.
We can't have a generic
From
orInto
implementation that converts from oneOffset
type into another because the standard library has a blanket implementation ofFrom<T> for T
. For the same reason we can't have a genericFrom
orInto
implementation that converts from oneDateTime<Tz>
into another.So we can and do have implementations to convert between
DateTime<Utc>
,DateTime<FixedOffset>
andDateTime<Local>
. But anyTimeZone
type outside chrono doesn't have this convenience, such as the one in chrono-tz.I propose to add a
FromOffset
trait thatOffset
types can implement to convert from any genericOffset
. And to add aDateTime::to_timezone
method to conveniently convert aDateTime<Tz>
into another type.If we implement
FromOffset
in chrono-tz it we can do nice things such as converting fromFixedOffset
to aTz
time zone for a fixed offset, or eventually fromLocalOffset
(#1563) to aTz
with the same time zone if possible.