Skip to content

Calling toISOString on a Duration object does not return weeks #2859

@behdi

Description

@behdi

Describe the bug
There's a weird behavior when it comes to getting an ISO duration string from the dayjs's duration object. For example:

dayjs.duration({ year:1, week: 2 }).toISOString(); // 'P1Y14D'
dayjs.duration('P2Y3W5D').toISOString(); // 'P2Y26D'

Expected behavior
It'd be really great if weeks weren't converted to days. So we'd get these in the output:

dayjs.duration({ year:1, week: 2 }).toISOString(); // 'P1Y2W'
dayjs.duration('P2Y3W5D').toISOString(); // 'P2Y3W5D'

Information

  • Day.js Version: v1.11.8
  • OS: Linux
  • Browser: Brave v 1.77.97
  • Time zone: GMT+3:30

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