break;
case 'MMM' : // fall through to MMMM
case 'MMMM' :
- a = getLangDefinition().monthsParse(input);
+ a = getLangDefinition(config._l).monthsParse(input);
// if we didn't find a month name, mark the date as invalid.
if (a != null) {
datePartArray[1] = a;
return new Moment(config);
}
- moment = function (input, format) {
+ moment = function (input, format, lang) {
return makeMoment({
_i : input,
_f : format,
+ _l : lang,
_isUTC : false
});
};
// creating with utc
- moment.utc = function (input, format) {
+ moment.utc = function (input, format, lang) {
return makeMoment({
_useUTC : true,
_isUTC : true,
+ _l : lang,
_i : input,
_f : format
});
test.expect(2);
test.equal(moment("-1000-01-01", "YYYYY-MM-DD").toDate().getFullYear(), -1000, "parse BC 1,001");
test.equal(moment.utc("-1000-01-01", "YYYYY-MM-DD").toDate().getUTCFullYear(), -1000, "parse utc BC 1,001");
+ test.done();
+ },
+
+ "parsing into a language" : function (test) {
+ test.expect(2);
+
+ moment.lang('parselang', {
+ months : "one_two_three_four_five_six_seven_eight_nine_ten_eleven_twelve".split('_'),
+ monthsShort : "one_two_three_four_five_six_seven_eight_nine_ten_eleven_twelve".split("_")
+ });
+
+ moment.lang('en');
+
+ test.equal(moment('2012 seven', 'YYYY MMM', 'parselang').month(), 6, "should be able to parse in a specific language");
+
+ moment.lang('parselang');
+
+ test.equal(moment('2012 july', 'YYYY MMM', 'en').month(), 6, "should be able to parse in a specific language");
+
test.done();
}
};