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

Added Offset support to Local #305

Closed
wants to merge 2 commits into from
Closed

Conversation

araspik
Copy link

@araspik araspik commented Feb 22, 2019

This would be really useful when trying to convert DateTime<Local> to DateTime<FixedOffset>, allowing this simple code:

local_datetime.with_timezone(Local.fix())

instead of the much longer current solutions.
Note that no tests are added; This was a quick solution (even though I dug through both time and chrono's docs for a bit).
Improvements are definitely possible, but this is a good start.

This would be really useful when trying to convert `DateTime<Local>` to `DateTime<FixedOffset>`, allowing this simple code:
```rust
local_datetime.with_timezone(Local.fix())
```
instead of the much longer current solutions.
Note that no tests are added; This was a quick solution (even though I dug through both `time` and `chrono`'s docs for a bit).
Improvements are definitely possible, but this is a good start.
@araspik
Copy link
Author

araspik commented Feb 22, 2019

It seems that Travis CI tests on Mac (w/ Rust 1.13.0) are broken (something about unions)?

@mqudsi
Copy link
Contributor

mqudsi commented Apr 8, 2019

@araspik #271 fixes the root issue by adding Into and From for all the datetime combinations, that should probably suffice for your needs?

@ErichDonGubler
Copy link

Wait, #271 actually just sets the seconds offset of the FixedOffset to be 0, doesn't it? Is that actually what we want here?

@quodlibetor
Copy link
Contributor

Yeah #271 allows converting Local to e.g. Utc, but this would allow converting to a FixedOffset that is the same as the Local Offset. If this got some tests I'd be happy to merge it.

Rebasing on top of master will fix the 1.13 tests.

@djc djc deleted the branch chronotope:master August 29, 2022 08:43
@djc djc closed this Aug 29, 2022
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

Successfully merging this pull request may close these issues.

5 participants