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

Add std::convert::From conversion between different DateTime offsets #271

Merged
merged 5 commits into from
Apr 8, 2019

Conversation

mqudsi
Copy link
Contributor

@mqudsi mqudsi commented Aug 12, 2018

Adds conversion to/from Utc, Local, and FixedOffset. Originally planned
to go through NaiveDateTime, but it seems that is not necessary?

Ref #263

Adds conversion to/from Utc, Local, and FixedOffset. Originally planned
to go through NaiveDateTime, but it seems that is not necessary?
Copy link
Contributor

@quodlibetor quodlibetor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable, other than adding some doccos and that you need to import some items into scope.

src/datetime.rs Show resolved Hide resolved
Documentation added to both `impl`s and functions so that they are
visible to both users perusing the online documentation and in
autocomplete/intellisense engines.
mqudsi added a commit to mqudsi/chrono that referenced this pull request Sep 6, 2018
As discussed in chronotope#263. Note that this breaks existing code that did not
explicitly specify the offset in calls to `DateTime::parse_from_*`, as
they are now ambiguous.

Relies on chronotope#271 for conversion back into `DateTime<Utc>` from
`DateTime<FixedOffset>` as the latter is used under the hood.
@mqudsi
Copy link
Contributor Author

mqudsi commented Sep 6, 2018

Should be ready for review, @quodlibetor

@mqudsi
Copy link
Contributor Author

mqudsi commented Oct 3, 2018

@quodlibetor did you get a chance to review this?

@mqudsi mqudsi changed the title [WIP] Add initial implementation of std::convert::From for DateTime offsets Add initial implementation of std::convert::From for DateTime offsets Oct 3, 2018
@mqudsi
Copy link
Contributor Author

mqudsi commented Dec 6, 2018

gentle bump

@theduke
Copy link

theduke commented Jan 25, 2019

A gentle bump from me, those conversions would be very useful.

@quodlibetor
Copy link
Contributor

Sorry this fell of my radar!

It looks like the test failures are just a simple use offset::Local away @mqudsi if you would like to get it passing, and add yourself to the changelog I will be happy to merge.

Thanks!

@ErichDonGubler
Copy link

ErichDonGubler commented Apr 8, 2019

@mqudsi, is there anything left to do on this besides just fixing the test failures? I'm anxious to be able to use this. :P

@mqudsi
Copy link
Contributor Author

mqudsi commented Apr 8, 2019

Those aren't CI test failures, they're actual build errors. The code has always compiled for me (my only rule is never commit something that doesn't build). Perhaps it has to do with the rustc version the build pipeline is (was?) using. On my end, it builds and passes all the tests:


test result: ok. 212 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

mqudsi@ZBOOK /m/c/U/m/r/chrono> git branch
  master
* offset_convert
  utc_from_str
mqudsi@ZBOOK /m/c/U/m/r/chrono> git rev-parse HEAD
973c603d7af0a0573a1fc43c430cd93f243a1eeb

Actually, it seems that use offset::Local was gated on the clock feature. Rather than ungating the use declaration, I presume the right thing to do here would be to similarly gate the conversion functions relying on clock functionality.

@quodlibetor
Copy link
Contributor

That does make sense, if we can get this merged that would be great!

@mqudsi
Copy link
Contributor Author

mqudsi commented Apr 8, 2019

Updated w/ the changes requested. Now builds for me locally with --no-default-features.

@mqudsi
Copy link
Contributor Author

mqudsi commented Apr 8, 2019

Thanks, @quodlibetor. btw my changelog.md updates presume this is going into a 0.4.6 release. Feel free to change.

@mqudsi mqudsi changed the title Add initial implementation of std::convert::From for DateTime offsets Add std::convert::From conversion between different DateTime offsets Apr 8, 2019
mqudsi added a commit to mqudsi/chrono that referenced this pull request Apr 8, 2019
As discussed in chronotope#263. Note that this breaks existing code that did not
explicitly specify the offset in calls to `DateTime::parse_from_*`, as
they are now ambiguous.

Relies on chronotope#271 for conversion back into `DateTime<Utc>` from
`DateTime<FixedOffset>` as the latter is used under the hood.
@quodlibetor quodlibetor merged commit bcdc66a into chronotope:master Apr 8, 2019
@quodlibetor
Copy link
Contributor

thanks @mqudsi for this change and thanks @ErichDonGubler for the ping pushing it over the finish line!

mqudsi added a commit to mqudsi/chrono that referenced this pull request Aug 31, 2022
As discussed in chronotope#263. Note that this breaks existing code that did not
explicitly specify the offset in calls to `DateTime::parse_from_*`, as
they are now ambiguous.

Relies on chronotope#271 for conversion back into `DateTime<Utc>` from
`DateTime<FixedOffset>` as the latter is used under the hood.
mqudsi added a commit to mqudsi/chrono that referenced this pull request Aug 31, 2022
As discussed in chronotope#263. Note that this breaks existing code that did not
explicitly specify the offset in calls to `DateTime::parse_from_*`, as
they are now ambiguous.

Relies on chronotope#271 for conversion back into `DateTime<Utc>` from
`DateTime<FixedOffset>` as the latter is used under the hood.
djc pushed a commit that referenced this pull request Sep 12, 2022
As discussed in #263. Note that this breaks existing code that did not
explicitly specify the offset in calls to `DateTime::parse_from_*`, as
they are now ambiguous.

Relies on #271 for conversion back into `DateTime<Utc>` from
`DateTime<FixedOffset>` as the latter is used under the hood.
Zomtir added a commit to Zomtir/chrono that referenced this pull request Mar 22, 2023
- Creates a global Error enum
- Breaks backwards compatiblility mainly because of promoting fallable functions (chronotope#263)
- Some tests still fall
- Not all doctests are fixed
- to_naive_datetime_with_offset function is broken and needs fixing
- serde related stuff is not checked properly

This is a rebase of chronotope#817 onto the 0.5 main branch. Main differences:

- Unify three different error structs
- Removed ErrorKind
- Adapted a lot of unit tests
- Removed some commits from presumably unrelated branches (chronotope#829) or
  mainlined commits (chronotope#271)

Co-authored-by: John-John Tedro <udoprog@tedro.se>
jtmoon79 added a commit to jtmoon79/chrono that referenced this pull request May 28, 2023
More tests for combinations of `DateTime::into`.

Follow-up to Pull Request chronotope#271.
jtmoon79 added a commit to jtmoon79/chrono that referenced this pull request May 28, 2023
More tests for combinations of `DateTime::into`.

Follow-up to Pull Request chronotope#271.
jtmoon79 added a commit to jtmoon79/chrono that referenced this pull request May 28, 2023
More tests for combinations of `DateTime::into`.

Follow-up to Pull Request chronotope#271.
Issue chronotope#263
jtmoon79 added a commit to jtmoon79/chrono that referenced this pull request May 28, 2023
More tests for combinations of `DateTime::into`.

Follow-up to Pull Request chronotope#271.
jtmoon79 added a commit to jtmoon79/chrono that referenced this pull request Sep 21, 2023
More tests for combinations of `DateTime::into`.

Follow-up to Pull Request chronotope#271.
jtmoon79 added a commit to jtmoon79/chrono that referenced this pull request Sep 21, 2023
More tests for combinations of `DateTime::into`.

Follow-up to Pull Request chronotope#271.
jtmoon79 added a commit to jtmoon79/chrono that referenced this pull request Sep 21, 2023
More tests for combinations of `DateTime::into`.

Follow-up to Pull Request chronotope#271.
jtmoon79 added a commit to jtmoon79/chrono that referenced this pull request Sep 21, 2023
More tests for combinations of `DateTime::into`.

Follow-up to Pull Request chronotope#271.
jtmoon79 added a commit to jtmoon79/chrono that referenced this pull request Sep 25, 2023
More tests for combinations of `DateTime::into`.

Follow-up to Pull Request chronotope#271.
jtmoon79 added a commit to jtmoon79/chrono that referenced this pull request Sep 25, 2023
More tests for combinations of `DateTime::into`.

Follow-up to Pull Request chronotope#271.
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.

4 participants