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 strict cannot parse 1-2 digit milliseconds #1331

Open
fretfan opened this issue Jan 12, 2021 · 5 comments
Open

customParseFormat strict cannot parse 1-2 digit milliseconds #1331

fretfan opened this issue Jan 12, 2021 · 5 comments

Comments

@fretfan
Copy link

fretfan commented Jan 12, 2021

When using customParseFormat with strict mode enabled cannot parse milliseconds in 1-, 2-digit (S or SS pattern). Results in "Invalid Date".
Only 3-digits are parsed fine.
YYYY-MM-DDTHH:mm:ss.SSS pattern is OK
YYYY-MM-DDTHH:mm:ss.SS and YYYY-MM-DDTHH:mm:ss.S patterns are not OK

See jsfiddle: https://jsfiddle.net/4t5yk0ju/1/

@fretfan
Copy link
Author

fretfan commented Jan 22, 2021

Is there any progress with this? Is this a bug or am I missing some configuration properties?

@fretfan
Copy link
Author

fretfan commented Jan 27, 2021

@iamkun can you give any information about this?

@lsorin77
Copy link

I am having a similar issue, e.g. dayjs('04:59:00.900 PM', 'h:mm:ss.SSS A', true) returns InvalidDate. Works in moment.

@BePo65
Copy link
Contributor

BePo65 commented May 31, 2022

The problem is that dayjs uses format to identify strict matches when parsing, but 'format' does not have a S or SS format token. Therefore the test for strictness fails.

PR #1914 solves this topic.

@janardhanbobba522
Copy link

janardhanbobba522 commented Oct 17, 2022

I'm facing the same issue with the format

Issue while using "S" and "SS" in the format
dayjs().format("YYYY-MM-DD HH:mm.S"); // '2022-10-17 11:37.S',
dayjs().format("YYYY-MM-DD HH:mm.SS"); // '2022-10-17 11:37.SS',

Works fine
dayjs().format("YYYY-MM-DD HH:mm.SSS"); // '2022-10-17 11:37.983'

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

4 participants