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 Date/Time<T> to Date/Time<U> #4

Closed
Kroisse opened this issue Aug 29, 2014 · 2 comments
Closed

Convert Date/Time<T> to Date/Time<U> #4

Kroisse opened this issue Aug 29, 2014 · 2 comments

Comments

@Kroisse
Copy link
Contributor

Kroisse commented Aug 29, 2014

rust-chrono has several methods which convert NaiveDate/Time to Date/Time<Off>, but there's no method which do Date/Time<T> to Date/Time<U>, where T and U are different Offsets.

There are two ways of converting the offset of the date/time object:

  • Preserve all of other fields, and replace only the offset info. This behavior likes Python's datetime.replace(tzinfo=new_tz). The duration between the result and the original will be same as a distance of their offsets.
  • Preserve the time, and adjust the date and time data. This behavior likes Python's datetime.astimezone(new_tz). They should have same UTC timestamp that the result and the original.
@Kroisse
Copy link
Contributor Author

Kroisse commented Aug 29, 2014

This could be critical, because there is no way to make today or now from FixedOffset.

@lifthrasiir
Copy link
Contributor

This is now possible with with_offset. Closing.

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