-
Notifications
You must be signed in to change notification settings - Fork 19
Implement DateTime
round method
#88
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
Conversation
src/iso.rs
Outdated
_ => { | ||
return Err(TemporalError::range() | ||
.with_message("Invalid temporal unit provided to Time.round.")) | ||
.with_message("Invalid smallestUNit value for time rounding.")) |
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.
.with_message("Invalid smallestUNit value for time rounding.")) | |
.with_message("Invalid smallestUnit value for time rounding.")) |
6837488
to
3d7face
Compare
src/iso.rs
Outdated
((((i128::from(self.hour) * 60 + i128::from(self.minute)) * 60 | ||
+ i128::from(self.second)) | ||
* 1000 | ||
+ i128::from(self.millisecond)) | ||
* 1000 | ||
+ i128::from(self.microsecond)) | ||
* 1000 | ||
+ i128::from(self.nanosecond) |
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.
Nit: I think this could benefit from separating it on several variables, even if they're just used once. Also applies to the other branches that do a big operation like this.
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.
Yeah, it would probably help with the readability.
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.
Nice work!
This PR implements
DateTime:round
. In order to do this,IsoDateTime::round
needed to be implemented, andIsoTime::round
was updated to the current specification version