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

subISOWeekYears and addISOWeekYears change date's time, even when adding/subtracting 0 ISO weeks #3368

Open
gregsadetsky opened this issue Mar 10, 2023 · 0 comments

Comments

@gregsadetsky
Copy link

repro:

const originalDT = parseISO("2023-03-10T00:00:00Z");
// adding 0 iso week years -- prints -68400000
console.log(addISOWeekYears(originalDT, 0) - originalDT);
// substracting 0 iso week years -- prints -68400000
console.log(subISOWeekYears(originalDT, 0) - originalDT);

as far as I can see, the source of this problem is that:

  • subISOWeekYears uses addISOWeekYears internally, so they both exhibit the same issue
  • addISOWeekYears usessetISOWeekYear internally
  • setISOWeekYear uses startOfISOWeekYear internally
  • startOfISOWeekYear uses startOfISOWeek internally
  • startOfISOWeek uses startOfWeek internally
  • finally, startOfWeek calls .setHours(0, 0, 0, 0) internally to set the date of the object that's returned through the chain described above

Thanks!

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