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

addISOWeekYears resets times to 0:00:00 #1757

Open
justingrant opened this issue May 7, 2020 · 1 comment · May be fixed by #3808
Open

addISOWeekYears resets times to 0:00:00 #1757

justingrant opened this issue May 7, 2020 · 1 comment · May be fixed by #3808

Comments

@justingrant
Copy link
Contributor

justingrant commented May 7, 2020

addISOWeekYears resets times to midnight local time. I didn't find this behavior in any other date-fns APIs.

Repro:

// time zone: America/Los_Angeles
const base = new Date(2020, 4, 8, 3);
console.log (base)
// Fri May 08 2020 03:00:00 GMT-0700 (Pacific Daylight Time)
const addOneIsoYear = addISOWeekYears(base, 1)
console.log (addOneIsoYear)
// Fri May 14 2021 00:00:00 GMT-0700 (Pacific Daylight Time)
// note that the time is lost.
@kossnocorp
Copy link
Member

kossnocorp commented May 11, 2020

That's definitely unexpected behavior. The problem is in setISOWeekYear that sets the time to midnight.

It's not consistent with the rest of the library and worth fixing. My only fear is that some folk rely on this behavior, and this would be a breaking change.

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

Successfully merging a pull request may close this issue.

2 participants