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/sub Days #784

Merged
merged 3 commits into from Aug 29, 2022
Merged

add/sub Days #784

merged 3 commits into from Aug 29, 2022

Conversation

esheppa
Copy link
Collaborator

@esheppa esheppa commented Aug 17, 2022

This matches the work done by @avantgardnerio and @djc with the Months datatype but for calendar Days.

This should resolve #339 and #290 and is relevant to the clarification in #100.

Potential future work could:

  • Deprecate the days and weeks helper functions on Duration as they are somewhat misleading, directing users to use Days instead
  • Potentially deprecate succ and pred on NaiveDate - although sometimes it's nice to have multiple ways to do something
  • Remove/deprecate the Add<Duration> and Sub<Duration> impls for NaiveDate

This is a bit light on documentation as I'm not sure whether this is wanted or not. If the idea here is looking good, I'll add more docs.

src/naive/date.rs Outdated Show resolved Hide resolved
src/naive/date.rs Outdated Show resolved Hide resolved
src/naive/date.rs Outdated Show resolved Hide resolved
src/naive/datetime/mod.rs Outdated Show resolved Hide resolved
src/naive/date.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

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

LGTM with two style suggestions.

src/naive/date.rs Outdated Show resolved Hide resolved
src/naive/date.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

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

One more minor nit I missed the first time around.

src/datetime/mod.rs Outdated Show resolved Hide resolved
Copy link

@avantgardnerio avantgardnerio left a comment

Choose a reason for hiding this comment

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

Looks great!

docs fixes

improve checked impls
@esheppa
Copy link
Collaborator Author

esheppa commented Aug 24, 2022

Having thought about this a bit, I think I need to add some tests before this gets merged 😄

@esheppa
Copy link
Collaborator Author

esheppa commented Aug 26, 2022

I've reused the tests from test_date_add/sub - this should be useful as we want to keep these even if the impl Add/Sub<Duration> for NaiveDate is removed

@djc djc changed the base branch from main to 0.4.x August 29, 2022 08:55
@djc djc merged commit 42ca8ca into chronotope:0.4.x Aug 29, 2022
@esheppa esheppa deleted the add-days-datatype branch August 29, 2022 11:02
@esheppa
Copy link
Collaborator Author

esheppa commented Aug 29, 2022

@djc - what is the best way to get these commits into main as well - should we periodically PR 0.4.x into main?

@djc
Copy link
Contributor

djc commented Aug 29, 2022

Yes, I think so.

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.

There is no way to add a "day" to a DateTime
3 participants