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

Creating an DateTime<Tz> instance from a DateTime<Local> #83

Closed
WhyNotHugo opened this issue Sep 8, 2022 · 4 comments
Closed

Creating an DateTime<Tz> instance from a DateTime<Local> #83

WhyNotHugo opened this issue Sep 8, 2022 · 4 comments

Comments

@WhyNotHugo
Copy link
Contributor

I'm trying to create a rrule::RRuleSet via its new() method, but can't figure out how to create a DateTime<Tz> instance (which is what this method requires).

I essentially have a DTSTART:19700101T000000 string as a starting point, and use the following to get a DateTime instance:

chrono::offset::Local.datetime_from_str(value, "%Y%m%dT%H%M%SZ")?

However, this returns a DateTime<Local>, and I can't quite figure out how to convert that to DateTime<Tz>. I intuitively think that new should maybe have the signature fn new<T>(dt_start: DateTime<T>) where T: TimeZone. I've no idea if this makes sense for all the rest of codebase, but it would allow using any TimeZone (including Local).

For context, I'm trying to parse VTIMEZONE entries, so I'm trying to construct this RRuleSet to then add other relevant fields to it (e.g.: RDATE).

@WhyNotHugo
Copy link
Contributor Author

I intuitively think that new should maybe have the signature fn new<T>(dt_start: DateTime<T>) where T: TimeZone.

Actually, this seems to be what's missing for my approach to work. This would also cover #24 and #36. I might have a PoC for this soon.

@fmeringdal
Copy link
Owner

Hey!

Would this work for you?

rrule::Tz::LOCAL.datetime_from_str(s, "%Y%m%dT%H%M%SZ")?

@WhyNotHugo
Copy link
Contributor Author

Yup, it does, thanks. I think I was trying to use the wrong Local.

1 similar comment
@WhyNotHugo
Copy link
Contributor Author

Yup, it does, thanks. I think I was trying to use the wrong Local.

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

2 participants