Skip to content

Duration plugin registers iso8601 period formatted input wrongly #2985

@johnche

Description

@johnche

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

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions