moment-timezone
moment-timezone copied to clipboard
after setDefault, in strict mode toDate() is not working as expected
Chrome | Windows 10 | moment and time zone latest version.
In strict mode, When I set the default time zone, the toDate() is not as working expected. see the quoted output below the code. toDate() should return an InValid Date, instead it prints the date time value.
moment.tz.setDefault(moment.tz.guess());
console.log("TimeZone: "+moment().tz());
console.log('Parse Check Time:' + moment('2017-08/21', 'YYYYMMDD', true).toDate());
console.log('Parse Check format:' + moment('2017-08/21', 'YYYYMMDD', true).format());
TimeZone: Asia/Calcutta Parse Check Time:Mon Aug 21 2017 05:30:00 GMT+0530 (India Standard Time) Parse Check format:Invalid date
Confirmed. Not sure the cause. Will investigate. Thanks!
Not sure if it's fully related, but when I setDefault to UTC I cannot create a moment instance from a string:
import moment from 'moment';
import 'moment-timezone';
moment.tz.setDefault('UTC');
moment('2017-10-18 10:00:00'); // moment.utc("2017-10-18T10:00:00.000+00:00")
moment('2017-10-18 10:00:00').format('X'); // '1508320800'
moment(moment('2017-10-18 10:00:00').format('X'), 'X'); // moment.utc("-000NaN--NaN--NaNT-NaN:-NaN:-NaN.-NaN+00:00")
This was working on moment 2.18.1. Now I'm working moment 2.19.1.
Thanks.