iamkun / iamkun/dayjs

customParseFormat throws wrong time

Open
#1,742 0 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

When use dayjs.extend(require("dayjs/plugin/customParseFormat")) it gives the wrong time. I guess this is something to do with format.

Seems like it's happening from dayjs(this._value, "HH:mm").
dayjs(this._value, "HH:mm") --> throw wrong time
dayjs(this._value).format('HH:mm') --> throw right time

![Screen Shot 2021-12-14 at 9 19 43 AM](https://user-images.githubusercontent.com/8846467/146047829-d2ab6d91-92b4-44bb-8990-a1f2d06ae8bd.png)

Without using customParseFormat plugin(Expected behavior):
![Screen Shot 2021-12-13 at 4 29 10 PM](https://user-images.githubusercontent.com/8846467/145911410-f7e5a24f-4566-4b7e-b9f1-841a64162ee6.png)
![Screen Shot 2021-12-13 at 4 31 12 PM](https://user-images.githubusercontent.com/8846467/145911411-83c5cb40-67c8-4d3a-a2df-ff4f8f599dd7.png)

With using customParseFormat plugin:
![Screen Shot 2021-12-13 at 4 28 36 PM](https://user-images.githubusercontent.com/8846467/145911467-16531bd1-4185-4fdd-a071-adfe7290ca5e.png)
![Screen Shot 2021-12-13 at 4 31 41 PM](https://user-images.githubusercontent.com/8846467/145911470-e273e457-f0e8-453f-a574-0d4bffca4bea.png)

**Information**
- Day.js Version - 1.10.7
- OS: MacOS
- Browser: Chrome Version 96.0.4664.93
- Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)]

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported difference between dayjs(this._value, "HH:mm") with customParseFormat and dayjs(this._value).format('HH:mm'), using the stated Day.js version and timezone details. Trace the customParseFormat plugin entry point and compare its handling of the HH:mm input with the expected time; done means the reported parsing case produces the expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.