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

Minutes or smaller setters don't account for fall-back transitions

Open leo108 opened this issue 9 years ago • 1 comments

Here is my code:

moment.tz.setDefault('America/Los_Angeles');
var date = moment('2016-11-06'); // the PDT to PST day
console.log(date.clone().seconds(36000).format()); // 2016-11-06T09:00:00-08:00
console.log(date.clone().hours(10).format()); // 2016-11-06T10:00:00-08:00

Is that designed as that or a bug ?

leo108 avatar Oct 24 '16 23:10 leo108

Confirmed:

var dt = '2016-11-06';
var z = 'America/Los_Angeles';
moment.tz(dt, z).hours(10).format()               // "2016-11-06T10:00:00-08:00"  (ok)
moment.tz(dt, z).minutes(600).format()            // "2016-11-06T09:00:00-08:00"  (bad)
moment.tz(dt, z).seconds(36000).format()          // "2016-11-06T09:00:00-08:00"  (bad)
moment.tz(dt, z).milliseconds(36000000).format()  // "2016-11-06T09:00:00-08:00"  (bad)

Without moment-timezone, and with local time set to Pacific, it works as expected:

var dt = '2016-11-06';
moment(dt).hours(10).format()               // "2016-11-06T10:00:00-08:00"  (ok)
moment(dt).minutes(600).format()            // "2016-11-06T10:00:00-08:00"  (ok)
moment(dt).seconds(36000).format()          // "2016-11-06T10:00:00-08:00"  (ok)
moment(dt).milliseconds(36000000).format()  // "2016-11-06T10:00:00-08:00"  (ok)

mattjohnsonpint avatar Oct 26 '16 18:10 mattjohnsonpint