Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative durations #811

Merged
merged 4 commits into from
Sep 1, 2020
Merged

Negative durations #811

merged 4 commits into from
Sep 1, 2020

Commits on Sep 1, 2020

  1. Split out SubtractTime as an abstract operation

    It's odd that we have AddTime but not SubtractTime. Regardless, we'll
    need to have it as a separate operation since it will be used from two
    places for negative duration support.
    ptomato committed Sep 1, 2020
    Configuration menu
    Copy the full SHA
    9a2b851 View commit details
    Browse the repository at this point in the history
  2. Negative durations

    Changes Temporal.Duration to allow negative values in the fields, as
    long as all the fields have the same sign. Adds negated() and abs()
    methods to Temporal.Duration, and a sign property.
    
    On all types with arithmetic, subtracting a negative duration is
    equivalent to adding the absolute value of that duration, and adding a
    negative duration is equivalent to subtracting the absolute value of
    that duration.
    
    Closes: #782
    ptomato committed Sep 1, 2020
    Configuration menu
    Copy the full SHA
    3625341 View commit details
    Browse the repository at this point in the history
  3. Allow difference() to return negative durations

    This undoes the work in commit d84653e
    although it's not exactly a revert, because the situation before that
    was that durations were always positive. We also don't reinstate the
    behaviour of never returning a duration larger than 12 hours.
    
    Now, for all types, calling smaller.difference(larger) will result in a
    negative duration.
    
    See: #782
    ptomato committed Sep 1, 2020
    Configuration menu
    Copy the full SHA
    acff715 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    93c64e2 View commit details
    Browse the repository at this point in the history