-
Notifications
You must be signed in to change notification settings - Fork 527
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 Default implementation for naive date types #506
Conversation
…Time * Added Default implmentation for DateTime and Date
Sorry for the delay! I agree that this is just kind of annoying to have not-implemented, and just using the unix epoch makes sense as a reasonably-surprising value. If you're willing to fix the tests and add implementations of this for the non-naive |
Hi @quodlibetor , sorry for my late reply, yes I'm more than happy to do that! I'll update the PR once I have the changes. |
Hi @quodlibetor, the test now pass and I've added |
src/naive/time.rs
Outdated
@@ -1341,6 +1341,20 @@ impl str::FromStr for NaiveTime { | |||
} | |||
} | |||
|
|||
/// The default for a NaiveTime is midnight, oo:oo:00 exactly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are the letter o instead of the number 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
src/naive/date.rs
Outdated
/// | ||
/// # Example | ||
/// | ||
/// ~~~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we recently (in between your submission of this PR and now) swapped all the doctests to use backticks to be more inline with other rust code. If you feel like changing these that'd be appreciated, but your call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the docs from the Default
impl to use backticks!
* Fixed typo in NaiveTime docs for Default
Hello @quodlibetor hope you had a nice holiday, I simply wanted to know if anything more was required in order to have the PR merge onto master, happy to make any changes if needed! |
Thank you! |
I think |
This PR aims to add some Default implementations for some of the naive types. The currently added defaults are the following:
NaiveDateTime
has been set to1970-01-01 00:00:00
NaiveDate
has been set to1970-01-01
NaiveTime
has been set to00:00:00
The main reason for the PR is to help in struct definitions that wish to simply
#derive[Default]
but currently are not able to because on of their attributes is of the previously mentioned types, adding this change would help simplify the code in that particular scenario.