iamkun / iamkun/dayjs

parse time only string `HH:mm` in Duration plugin

Open
#2,179 9 comments 7 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 duration can parse time only string. Exemple: `$dayjs.duration('40:00')`
$dayjs is not able to parse such string and simply return an empty/invalid Object.
Capture d’écran, le 2022-12-28 à 20 02 51

**Expected behavior**
$dayjs should also be able to parse time only string as it was supported in moment.js, [see the documentation](https://momentjs.com/docs/#/durations/:~:text=The%20format%20is%20an%20hour%2C%20minute%2C%20second%20string%20separated%20by%20colons%20like%2023%3A59%3A59.%20The%20number%20of%20days%20can%20be%20prefixed%20with%20a%20dot%20separator%20like%20so%207.23%3A59%3A59.%20Partial%20seconds%20are%20supported%20as%20well%2023%3A59%3A59.999.)

```
moment.duration('23:59:59');
moment.duration('23:59:59.999');
moment.duration('7.23:59:59.999');
moment.duration('23:59'); // added in 2.3.0
```

**Information**
- Day.js Version 1.11.7
- OS: macOS
- Browser Chrome 108

Contributor guide

Open the contributing guide

Research direction

The issue names the Duration plugin but no source file or test. Start by locating its string-input parsing entry point and existing duration parsing tests; reproduce `23:59` and `23:59:59` first. Done means the documented time-only forms, including fractional seconds and day-prefixed input, parse like the examples and regression tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.