iamkun / iamkun/dayjs

Duration plugin registers iso8601 period formatted input wrongly

Open
#2,985 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

**Describe the bug**
dayjs duration plugin does not calculate hours and minutes properly when input string has minutes more than 60

```javascript
dayjs.duration('PT75M').minutes()
// 75

dayjs.duration('PT75M').hours()
// 0
```

This should be incorrect as Minutes should be a number from 0-59. `.format()` also fails in this regard (ie. `.format('H:m')` becomes `0:75`.

**Expected behavior**
```javascript
dayjs.duration('PT75M').minutes()
// 15

dayjs.duration('PT70M').hours()
// 1
```

**Information**
- Day.js Version 1.11.19
- OS: macOS Sequoia 15.6.1
- Browser Firefox
- Time zone: CET

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.