Open WhyNotHugo opened 2 years ago
Another good approach is to parse VTIMEZONE
into some special type first (e.g.: VTimeZone
).
And then some helper function to convert:
(icalendar::CalendarDateTime::WithTimezone, VTimeZone) -> chrono::DateTime
Ok, after re-reading the spec and looking closely at chrono's API, I think the best thing here is to implement a VTimeZone
type, which implements chrono::offset::TimeZone
. VTimeZone
should also impl TryFrom<icalendar::parser::Component>
.
Props of value-type UTC-OFFSET
can themselves be mapped to chrono::offset::Offset
.
I'd like to convert a
icalendar::CalendarDateTime::WithTimezone
to achrono::DateTime
.I don't think that a
chrono::offset::TimeZone
can be created with the TZ data inside an icalendar event. This TZ data is often missing info too -- usually transitions relevant to the date encoded are included, but not other unrelated transitions or exceptions.It might be simpler (or less error prone) to have just a helper method that converts the time to
chrono::DateTime<UTC>
.