moment-timezone icon indicating copy to clipboard operation
moment-timezone copied to clipboard

startOf('week') and endOf('week') incorrect across midnight transition into DST

Open irvingreid opened this issue 10 years ago • 2 comments

I'm getting what I think is an incorrect result with the Brazilian time zones, specifically with moment.endOf('week') on Chrome (46) and Firefox (43.0a2) with the browser in America/Toronto (currently EDT) time zone.

d = moment.tz('2015-10-16 20:00:00-0400', 'America/Cuiaba');
d.endOf('week').format()
  -> "2015-10-17T22:59:59-04:00"

The 'missing hour' in this transition is actually 00:00:00-04:00 to 01:00:00-03:00, so endOf('week') should be 23:59:59-0400.

It also misses endOf('week') in the following week:

d = moment.tz('2015-10-23T20:00:00-03:00', 'America/Cuiaba');
d.startOf('week').format()
   -> "2015-10-18T01:00:00-03:00"
d.endOf('week').format()
   -> "2015-10-25T00:59:59-03:00"

irvingreid avatar Oct 16 '15 15:10 irvingreid

Confirmed. I'll look into it. Thanks.

mattjohnsonpint avatar Oct 16 '15 19:10 mattjohnsonpint

The same is happening with me.

moment('2015-10-18', 'YYYY-MM-DD').format('YYYY-MM-DD HH:mm:ss')

The code above returns "2015-10-17 23:00:00" on my Brazilian timezone (America/Sao_Paulo).

comigor avatar Oct 22 '15 20:10 comigor