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

addDays rounds the amount without any hint in the documentation #3711

Open
mwaibel-go opened this issue Feb 15, 2024 · 0 comments
Open

addDays rounds the amount without any hint in the documentation #3711

mwaibel-go opened this issue Feb 15, 2024 · 0 comments

Comments

@mwaibel-go
Copy link

There is an issue with the addDays documentation

The problem with addDays documentation

I expected

const result = addDays(new Date('2024-02-15'), 0.5)

to be Fri Feb 16 2024 12:00:00. Instead it is Thu Feb 15 2024 00:00:00.

Suggested edits

Mention that the amount parameter is rounded to the nearest integer.

This also affects all functions that are only proxies to addDays, for instance subDays.

This might also affect the other {add,sub}{period} methods.

For reference: addDays(new Date('2024-02-15'), -0.9) is equal to addDays(new Date('2024-02-15'), -1), which means that the amount is always rounded down.

fazil-shaik pushed a commit to fazil-shaik/date-fns that referenced this issue Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant