// fall through to ZZ
case 'ZZ' :
isUsingUTC = true;
- a = input.match(timezoneParseRegex);
- if (a[1]) {
+ a = (input || '').match(timezoneParseRegex);
+ if (a && a[1]) {
timezoneHours = ~~a[1];
}
- if (a[2]) {
+ if (a && a[2]) {
timezoneMinutes = ~~a[2];
}
// reverse offsets
- if (a[0] === '+') {
+ if (a && a[0] === '+') {
timezoneHours = -timezoneHours;
timezoneMinutes = -timezoneMinutes;
}
ok(b.format('ZZ').match(/^[\+\-]\d{4}$/), b.format('ZZ') + ' ---> Something like "+0700"');
});
+test("format multiple with zone", 1, function() {
+ var b = moment('2012-10-08 -1200', ['YYYY ZZ', 'YYYY-MM-DD ZZ']);
+ equals(b.format('YYYY-MM'), '2012-10', 'Parsing multiple formats should not crash with different sized formats');
+});
+
test("isDST", 2, function() {
// In the US 2011 March 13 is Daylight Savings Day
var a = moment(new Date(2011, 2, 12, 0, 0, 0)),