diff --git a/src/plugin/customParseFormat/index.js b/src/plugin/customParseFormat/index.js index 73e48eb91..fc3b788f4 100644 --- a/src/plugin/customParseFormat/index.js +++ b/src/plugin/customParseFormat/index.js @@ -232,7 +232,10 @@ export default (o, C, d) => { this.$d = parseFormattedInput(date, format, utc) this.init() if (pl && pl !== true) this.$L = this.locale(pl).$L - if (isStrict && date !== this.format(format)) { + // use != to treat + // input number 1410715640579 and format string '1410715640579' equal + // eslint-disable-next-line eqeqeq + if (isStrict && date != this.format(format)) { this.$d = new Date('') } // reset global locale to make parallel unit test diff --git a/test/plugin/customParseFormat.test.js b/test/plugin/customParseFormat.test.js index 97fe8fb73..3b4e5f9cb 100644 --- a/test/plugin/customParseFormat.test.js +++ b/test/plugin/customParseFormat.test.js @@ -5,6 +5,7 @@ import '../../src/locale/ru' import uk from '../../src/locale/uk' import '../../src/locale/zh-cn' import customParseFormat from '../../src/plugin/customParseFormat' +import advancedFormat from '../../src/plugin/advancedFormat' import localizedFormats from '../../src/plugin/localizedFormat' dayjs.extend(customParseFormat) @@ -376,4 +377,8 @@ it('parse X x', () => { const input2 = '1410715640579' const format2 = 'x' expect(dayjs(input2, format2).valueOf()).toBe(moment(input2, format2).valueOf()) + + // x X starct parse requires advancedFormat plugin + dayjs.extend(advancedFormat) + expect(dayjs(input2, format2, true).valueOf()).toBe(moment(input2, format2, true).valueOf()) })