iamkun / iamkun/dayjs

Time parsing not lenient like moment

Open
#2,748 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Moment.js is able to do lenient time parsing by using parse format 'HH:mm a'. With that format, you can parse '4:26 PM', '4:26 pm', '4:26pm', '16:26', etc. But in dayjs, the format is exact and anything else is an `Invalid Date`. Is there a way to do more lenient time parsing?

**Expected behavior**
Emulate moment lenient time parsing behavior.

**Information**
- Day.js Version [e.g. v1.0.0] 1.11.13
- OS: [e.g. iOS] Mac OS 14.7
- Browser [e.g. chrome 62] Chrome 129
- Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)] GMT-4 EDT

Contributor guide

Open the contributing guide

Research direction

The issue names no source file, test, or entry point; begin by reproducing parsing for the listed inputs with the 'HH:mm a' format and compare the results with Moment.js. Done means Day.js accepts the documented lenient variants and handles invalid inputs consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.