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

customParseFormat doesn't work reliably with a or A #1525

Open
gr2m opened this issue Jun 7, 2021 · 1 comment
Open

customParseFormat doesn't work reliably with a or A #1525

gr2m opened this issue Jun 7, 2021 · 1 comment

Comments

@gr2m
Copy link

gr2m commented Jun 7, 2021

Describe the bug

Example

import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat.js";
dayjs.extend(customParseFormat);

console.log(
  dayjs("May 17, 2021 12:00pm", "MMMM D, YYYY H:mma", true).isValid()
);
// true

console.log(
  dayjs("May 17, 2021 1:00pm", "MMMM D, YYYY H:mma", true).isValid()
);
// false

I can paste the console.log statements into the developer tools console on https://day.js.org/ and get the same result.

Expected behavior

Parsing am/pm with a and AM/PM with A should set the hours offset as expected.

Information

  • Day.js Version: 1.10.5
  • OS: Mac OS X, Ubuntu Latest
  • Browser: latest Firefox, Chrome
  • Node: 14, 16
  • Time zone: GMT-07:00 DST (Pacific Daylight Time)
@BePo65
Copy link
Contributor

BePo65 commented May 29, 2022

The problem is the comma in the date / format string; dayjs cannot handle this. PR #1913 should fix that

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

2 participants