Open henriqueleite42 opened 9 months ago
Sorry, my mistake, I was seeing the wrong result
Actually, I don't believe that it's my mistake, the bug is really happening.
You have a comma in your example. I wonder if you have add()
defined somewhere. I just tested it out of curiosity in Node 20 on Windows and it works as expected.
Sorry, the comma was a typo that only exists in this example, but not in the real scenario where the bug happens.
The bug is real and it happens for .add(1, 'year')
too
const initial = dayjs.tz('2024-02-15').format('YYYY-MM-DD') // 2024-02-15
const expected= dayjs('2024-02-15').add(1, 'year').format('YYYY-MM-DD') // 2025-02-15
const result = dayjs.tz('2024-02-15').add(1, 'year').format('YYYY-MM-DD') // 2025-02-01
The bug only affects the day
EDIT: The bug only happens when timezone is set to
UTC
EDIT2: Looks like it is a problem with:.endOf('month')
when dealing withUTC
timezone EDIT3: I believe it has something to do with the fact that UTC does not returns an offset (since it isZERO
), I reproduced the same error withEurope/Lisbon
that has aZERO
offset too
Describe the bug Day is changed to the first day of the month
Information