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 new function roundToNearestHours #2752

Merged
merged 2 commits into from Mar 11, 2024

Conversation

sakamossan
Copy link
Contributor

ref #787 #928

Added roundToNearestHours, which is similar to roundToNearestMinutes.
If this is the right way to contribute, I will also implement roundToNearestDay to fix #928 (comment).

@sakamossan
Copy link
Contributor Author

ref #3132

@sakamossan sakamossan force-pushed the 928-round-to-nearest-hours branch 2 times, most recently from d4aaac4 to b31cdf8 Compare February 2, 2024 01:19
@sakamossan
Copy link
Contributor Author

@kossnocorp

Hello. It's been a while since I created the pull request, but I caught up changes with v3.
How can I getting review for this PR?

@kossnocorp
Copy link
Member

Hey, I'm back! Let me catch up with everything and I'll help you land the PR.

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";
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
import type { NearestHoursOptions, RoundingOptions } from "../types";
import type { NearestHoursOptions, RoundingOptions } from "../types.js";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in a923d47

Copy link
Member

@kossnocorp kossnocorp left a comment

Choose a reason for hiding this comment

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

Let's go!

sakamossan and others added 2 commits March 11, 2024 12:02
@kossnocorp kossnocorp merged commit 023e8a4 into date-fns:main Mar 11, 2024
7 checks passed
@kossnocorp
Copy link
Member

Shipped with date-fns@3.4.0

@monsonjeremy
Copy link

I'm not sure if this is intentional but this function can't be imported like import { roundToNearestHours } from 'date-fns'

Seems like it just needs the file included in the root index file. Happy to make a PR if that is desired.

@sakamossan
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Shipped
Development

Successfully merging this pull request may close these issues.

None yet

4 participants