Skip to content

Duration.formatTo returns incoherent values for duration of more than a year #1741

@florianOA-db

Description

@florianOA-db

Describe the bug
Duration.formatTo returns incoherent values for durations of more than a year.

To Reproduce

Duration.fromObject({ 
    milliseconds: Duration.fromObject({ years: 1, months: 2, days: 3 }).as('milliseconds')
}).toFormat('yyyy MM dd hh:mm:ss');
// returns '0001 02 08 00:00:00'
// there is 5 too many days

Duration.fromObject({ 
    milliseconds: Duration.fromObject({ years: 1, months: 2, days: 3 }).as('milliseconds')
}).shiftTo('year').toFormat('yyyy MM dd hh:mm:ss');
// returns 0001 02 02 03:17:15
// this is not even close to the expected value, from where do all those hours and minutes come from ?

Actual vs Expected behavior
The value expected from those 2 calls is 0001 02 03 00:00:00

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome 141
  • Luxon version 3.7.2
  • Your timezone Europe/Paris

Additional context
This worked fine before version 3.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions