mom = createUTC([2000, 1]).day(i);
if (strict && !this._fullWeekdaysParse[i]) {
- this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
- this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
- this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
+ this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
+ this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
+ this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
}
if (!this._weekdaysParse[i]) {
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
'preserve global locale in case of bad locale id');
});
+test('when in strict mode with inexact parsing, treat periods in short weekdays literally, not as the regex-period', function (assert) {
+ moment.defineLocale('periods-in-short-weekdays', {
+ weekdays : 'Monday_Tuesday_Wednesday_Thursday_Friday_Saturday_Sunday'.split('_'),
+ weekdaysShort : 'mon_t...s_wed_thurs_fri_sat_sun'.split('_'),
+ weekdaysParseExact : false
+ });
+
+ moment().locale('periods-in-short-weekdays');
+ assert.equal(moment('thurs', 'ddd', true).format('dddd'), 'Thursday');
+});
+
+test('when in strict mode with inexact parsing, treat periods in full weekdays literally, not as the regex-period', function (assert) {
+ moment.defineLocale('periods-in-full-weekdays', {
+ weekdays : 'Monday_T....day_Wednesday_Thursday_Friday_Saturday_Sunday'.split('_'),
+ weekdaysShort : 'mon_tues_wed_thurs_fri_sat_sun'.split('_'),
+ weekdaysParseExact : false
+ });
+
+ moment().locale('periods-in-full-weekdays');
+ assert.equal(moment('Thursday', 'dddd', true).format('ddd'), 'thurs');
+});
+
+test('when in strict mode with inexact parsing, treat periods in min-weekdays literally, not as the regex-period', function (assert) {
+ moment.defineLocale('periods-in-min-weekdays', {
+ weekdays : 'Monday_Tuesday_Wednesday_Thursday_Friday_Saturday_Sunday'.split('_'),
+ weekdaysMin : 'mon_t...s_wed_thurs_fri_sat_sun'.split('_'),
+ weekdaysParseExact : false
+ });
+
+ moment().locale('periods-in-min-weekdays');
+ assert.equal(moment('thurs', 'dd', true).format('dddd'), 'Thursday');
+});
+
// TODO: Enable this after fixing pl months parse hack hack
// test('monthsParseExact', function (assert) {