Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dayjs returns Invalid Date #1642

Open
srav09 opened this issue Sep 22, 2021 · 0 comments
Open

Dayjs returns Invalid Date #1642

srav09 opened this issue Sep 22, 2021 · 0 comments

Comments

@srav09
Copy link

srav09 commented Sep 22, 2021

Describe the bug
Dayjs returns Invalid Date if the date entered by a user starts with day name.

Example code:

import * as dayjs from 'dayjs';
import 'dayjs/locale/fr';

 var customParseFormat = require('dayjs/plugin/customParseFormat')
 dayjs.extend(customParseFormat);
 var localizedFormat = require('dayjs/plugin/localizedFormat')
 dayjs.extend(localizedFormat)
 var day = dayjs;
 day.locale('fr'); //Using french locale

  text = 'vendredi 1 janvier 2021 11:40:39 heure' ;
  format = 'dddd D MMMM YYYY h:mm:ss A';
  day(text, format, 'fr'); 

Executing the above line(day(text, format, 'fr')) is throwing the below error. It works only if the day name is given after YYYY. Example: '1 janvier 2021, vendredi 11:40:39 heure'.

ERROR: M {$L: 'fr', $u: undefined, $d: Invalid Date, $y: NaN, $M: NaN, …}

Screen Shot 2021-09-22 at 1 13 58 PM

Expected behavior
Dayjs should return correct Date if the date entered by a user starts with day name.

Information

  • Day.js Version - 1.10.7
  • OS - macOS Big Sur
  • Browser - Chrome 93.0.4577.82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant