-
Notifications
You must be signed in to change notification settings - Fork 174
No negative durations? #558
Copy link
Copy link
Closed
Labels
behaviorRelating to behavior defined in the proposalRelating to behavior defined in the proposalenhancementhas-consensusnon-prod-polyfillTHIS POLYFILL IS NOT FOR PRODUCTION USE!THIS POLYFILL IS NOT FOR PRODUCTION USE!spec-textSpecification text involvedSpecification text involved
Milestone
Metadata
Metadata
Assignees
Labels
behaviorRelating to behavior defined in the proposalRelating to behavior defined in the proposalenhancementhas-consensusnon-prod-polyfillTHIS POLYFILL IS NOT FOR PRODUCTION USE!THIS POLYFILL IS NOT FOR PRODUCTION USE!spec-textSpecification text involvedSpecification text involved
In docs for
Duration, I was surprised that no negative durations were allowed. This limitation seems to make DX much harder for subtractingDurations 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.