Dayjs: customParseFormat plugin make some mistakes

Created on 9 Nov 2020  路  4Comments  路  Source: iamkun/dayjs

Describe the bug

import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat';
// this is right
console.log(dayjs('2020-01-01', 'YYYY-MM-DD', true).isValid());// true

// using customParseFormat plugin
dayjs.extend(customParseFormat);

// this is wrong, after customParseFormat plugin loaded
console.log(dayjs('2020-01-01', 'YYYY-MM-DD', true).isValid());// false

Expected behavior
The second console.log should print true as the first one.

Information

  • Day.js Version 1.9.5
  • OS: Mac OS X 10.15.7
  • Browser : Chrome/86.0.4240.80
  • Time zone: GMT +08:00
released

Most helpful comment

Will fix soon in the next release.

All 4 comments

I've the same problem when I'm trying to use strict format:

This example should return true:

dayjs.extend(customParseFormat);
dayjs(
    '2020-11-08 19:34:39',
    'YYYY-MM-DD HH:mm:ss',
    true
  ).isValid() // false

https://repl.it/@alexw0/dayjs-test#index.js

Is this a bug or are we doing anything wrong?

I am actually noticing this is an issue between 1.9.4 and 1.9.5. I was seeing tests failing when we upgraded to 1.9.5 but they are not in 1.9.4.

Will fix soon in the next release.

:tada: This issue has been resolved in version 1.9.6 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

axelg12 picture axelg12  路  4Comments

prantlf picture prantlf  路  5Comments

fes300 picture fes300  路  5Comments

fundon picture fundon  路  5Comments

eugeneoshepkov picture eugeneoshepkov  路  3Comments