dddd : 'v("weekdays",t.day())',
w : '(a=new Date(t.year(),t.month(),t.date()-t.day()+5),b=new Date(a.getFullYear(),0,4),a=~~((a-b)/864e5/7+1.5))',
YY : 'p(t.year()%100,2)',
- YYYY : 't.year()',
+ YYYY : 'p(t.year(),4)',
a : 'm(t.hours(),t.minutes(),!0)',
A : 'm(t.hours(),t.minutes(),!1)',
H : 't.hours()',
}
// we store whether we used utc or not in the input array
input[7] = asUTC;
- date = asUTC ? new Date(Date.UTC.apply({}, input)) :
- new Date(input[0], input[1], input[2], input[3], input[4], input[5], input[6]);
+ date = new Date(0);
+ if (asUTC) {
+ date.setUTCFullYear(input[0], input[1], input[2]);
+ date.setUTCHours(input[3], input[4], input[5], input[6]);
+ } else {
+ date.setFullYear(input[0], input[1], input[2]);
+ date.setHours(input[3], input[4], input[5], input[6]);
+ }
date._a = input;
return date;
}
var expected = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split("_");
var i;
for (i = 0; i < expected.length; i++) {
- test.equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+ test.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
test.done();
},
test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
test.done();
}
-};
\ No newline at end of file
+};
"empty string with formats" : function(test) {
test.expect(3);
- test.equal(moment(' ', 'MM').format('YYYY-MM-DD HH:mm:ss'), '1900-01-01 00:00:00', 'should not break if input is an empty string');
- test.equal(moment(' ', 'DD').format('YYYY-MM-DD HH:mm:ss'), '1900-01-01 00:00:00', 'should not break if input is an empty string');
- test.equal(moment(' ', ['MM', "DD"]).format('YYYY-MM-DD HH:mm:ss'), '1900-01-01 00:00:00', 'should not break if input is an empty string');
+ test.equal(moment(' ', 'MM').format('YYYY-MM-DD HH:mm:ss'), '0000-01-01 00:00:00', 'should not break if input is an empty string');
+ test.equal(moment(' ', 'DD').format('YYYY-MM-DD HH:mm:ss'), '0000-01-01 00:00:00', 'should not break if input is an empty string');
+ test.equal(moment(' ', ['MM', "DD"]).format('YYYY-MM-DD HH:mm:ss'), '0000-01-01 00:00:00', 'should not break if input is an empty string');
test.done();
},