Skip to content

No negative durations? #558

@justingrant

Description

@justingrant

In docs for Duration, I was surprised that no negative durations were allowed. This limitation seems to make DX much harder for subtracting Durations and calculating differences between DateTime/Absolute/Date/Time values, because before doing the subtraction operation you'd need to check which one was greater.

This is also different behavior from all date libraries that I'm familiar with, all of which support negative results that can be returned from their equivalent of difference().

Would it be possible to relax this rule to support only the largest unit being negative? So you could have "-3 days" but not "3 days and -12 hours".

It's OK if there's no ISO serialization possible for negative durations, especially given that there are already other cases where the value is not ISO serializable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions