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

parse just TimeZone/Offset #1108

Closed
Benjscho opened this issue May 29, 2023 · 3 comments
Closed

parse just TimeZone/Offset #1108

Benjscho opened this issue May 29, 2023 · 3 comments

Comments

@Benjscho
Copy link

Benjscho commented May 29, 2023

Currently (if I'm reading the docs right) there's no way to parse just a TimeZone/Offset using the formats described in format::strftime.

I have a use case to parse an Offset, e.g., "UTC-0700" and return a DateTime object at midnight of the current day at that offset, essentially replicating the behaviour of date -d "UTC-0700". I have a workaround to have a default datetime string, and append the offset to be parsed to it, and then use DateTime::parse_from_str - is that the only way to do this at the moment?

Obviously no obligation to consider this as a feature, just wondering if there were any other standard ways for parsing Timezones/Offsets at the moment, or if it was on anyone's mind.

@djc
Copy link
Contributor

djc commented May 30, 2023

It's being discussed, see #1092.

@Benjscho
Copy link
Author

Ace, thankyou! I'll track that PR

@pitdicker
Copy link
Collaborator

With #1157 FixedOffset implements FromStr.

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

3 participants