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

Convert icalendar::CalendarDateTime::WithTimezone to chrono::DateTime #49

Open
WhyNotHugo opened this issue Sep 7, 2022 · 2 comments
Open

Comments

@WhyNotHugo
Copy link
Contributor

I'd like to convert a icalendar::CalendarDateTime::WithTimezone to a chrono::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>.

@WhyNotHugo
Copy link
Contributor Author

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

@WhyNotHugo
Copy link
Contributor Author

WhyNotHugo commented Sep 7, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant