Skip to content

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

Merged
merged 3 commits into from
Jul 22, 2024
Merged

Implement DateTime round method #88

merged 3 commits into from
Jul 22, 2024

Conversation

nekevss
Copy link
Member

@nekevss nekevss commented Jul 21, 2024

This PR implements DateTime:round. In order to do this, IsoDateTime::round needed to be implemented, and IsoTime::round was updated to the current specification version

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."))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.with_message("Invalid smallestUNit value for time rounding."))
.with_message("Invalid smallestUnit value for time rounding."))

@nekevss nekevss force-pushed the impl-dt-rounding branch from 6837488 to 3d7face Compare July 21, 2024 21:11
src/iso.rs Outdated
Comment on lines 685 to 692
((((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)
Copy link
Member

@jedel1043 jedel1043 Jul 21, 2024

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.

Copy link
Member Author

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.

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Nice work!

@jedel1043 jedel1043 merged commit 0fada43 into main Jul 22, 2024
5 checks passed
@jedel1043 jedel1043 deleted the impl-dt-rounding branch July 22, 2024 00:36
@nekevss nekevss added C-enhancement New feature or request C-api Changes related to the public API labels Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-api Changes related to the public API C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants