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 new function roundToNearestHours #2752
add new function roundToNearestHours #2752
Conversation
59e54a2
to
9f4f88a
Compare
ref #3132 |
d4aaac4
to
b31cdf8
Compare
Hello. It's been a while since I created the pull request, but I caught up changes with v3. |
Hey, I'm back! Let me catch up with everything and I'll help you land the PR. |
src/roundToNearestHours/index.ts
Outdated
import { getRoundingMethod } from "../_lib/getRoundingMethod/index.js"; | ||
import { constructFrom } from "../constructFrom/index.js"; | ||
import { toDate } from "../toDate/index.js"; | ||
import type { NearestHoursOptions, RoundingOptions } from "../types"; |
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.
import type { NearestHoursOptions, RoundingOptions } from "../types"; | |
import type { NearestHoursOptions, RoundingOptions } from "../types.js"; |
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 in a923d47
b31cdf8
to
a923d47
Compare
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.
Let's go!
Added `roundToNearestHours` function.
a923d47
to
e02e078
Compare
Shipped with |
I'm not sure if this is intentional but this function can't be imported like Seems like it just needs the file included in the root index file. Happy to make a PR if that is desired. |
@monsonjeremy Thanks for reporting! I've tested this in v3.6.0, and it seems the issue has been resolved. $ node --input-type=module -e '
import { roundToNearestHours } from "date-fns";
console.log(roundToNearestHours(new Date()))
'
2024-04-25T02:00:00.000Z Environment$ node --version
v18.13.0
$ cat package.json | jq -c .dependencies
{"date-fns":"^3.6.0"} Please let me know if my confirmation is not what you expected. |
ref #787 #928
Added
roundToNearestHours
, which is similar toroundToNearestMinutes
.If this is the right way to contribute, I will also implement
roundToNearestDay
to fix #928 (comment).