<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    Hi,<br>
    <br>
    I would also reinforce Stephen's early observation that the pattern
    for "until" methods in java.time includes those of the XXXDate
    classes, with a single Temporal parameter.  Period and Duration are
    similar values holding relative TemporalAmounts.<br>
    <pre>    public Period until(ChronoLocalDate endDateExclusive)</pre>
    In addition to Instant, the LocalTime class might also benefit from
    adding:<br>
    <pre>    public Duration until(LocalTime endExclusive)`</pre>
    The API design of java.time included an emphasis on consistent
    naming across the packages.<br>
    <br>
    Regards, Roger<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 5/2/24 4:01 PM, Naoto Sato wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:0ac5b3f0-a35f-41cc-bd48-a10035233226@oracle.com">`Temporal`
      interface is clear that its `minus` methods return objects of the
      same `Temporal` type, and `until` calculates the amount of time
      until another `Temporal` type. Introducing `Instant.minus` that
      returns `Duration` would be confusing to me. <br>
      <br>
      Naoto <br>
      <br>
      On 5/2/24 10:41 AM, Éamonn McManus wrote: <br>
      <blockquote type="cite">I'd say too that this makes intuitive
        sense based on algebra. If we have: <br>
        /instant1/ + /duration/ = /instant2/ <br>
        then we can subtract /duration/ from both sides: <br>
        /instant1 = instant2 - duration/ <br>
        or we can subtract /instant1/ from both sides: <br>
        /duration = instant2 - instant1/ <br>
        <br>
        There's no manipulation we can do that would cause us to try to
        add instants together, and it's a bit surprising for the API to
        allow the first subtraction but not the second. <br>
        I also think that if I see instant2.minus(instant1) it's
        immediately obvious to me what that means, while
        instant1.until(instant2) seems both less discoverable and less
        obvious. <br>
        <br>
        On Thu, 2 May 2024 at 10:29, Louis Wasserman <<a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:lowasser@google.com">lowasser@google.com</a> <a class="moz-txt-link-rfc2396E" href="mailto:lowasser@google.com"><mailto:lowasser@google.com></a>>
        wrote: <br>
        <br>
            That doesn't follow for me at all. <br>
        <br>
            The structure formed by Instants and Durations is an affine
        space <br>
            <a class="moz-txt-link-rfc2396E" href="https://en.wikipedia.org/wiki/Affine_space#Definition"><https://en.wikipedia.org/wiki/Affine_space#Definition></a>,
        with <br>
            instants the points and durations the vectors.  (An affine
        space is <br>
            a vector space without a distinguished origin, which of
        course <br>
            Instants don't have.)  It is 100% standard to use the minus
        sign for <br>
            the operation "point - point = vector," even when "point +
        point" is <br>
            not defined, and to use all the other standard idioms for <br>
            subtraction; the Wikipedia article uses "subtraction" and <br>
            "difference" ubiquitously. <br>
        <br>
            Personally, I'd be willing to live with a different name for
        the <br>
            operation, but consider "users keep getting it wrong" a
        strong <br>
            enough argument all by itself for a version with the swapped
        <br>
            argument order; it's not obvious to me that another API with
        the <br>
            same argument order adds enough value over Duration.between
        to <br>
            bother with. <br>
        <br>
            On Thu, May 2, 2024 at 10:04 AM Stephen Colebourne <br>
            <<a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:scolebourne@joda.org">scolebourne@joda.org</a> <a class="moz-txt-link-rfc2396E" href="mailto:scolebourne@joda.org"><mailto:scolebourne@joda.org></a>>
        wrote: <br>
        <br>
                On Thu, 2 May 2024 at 15:58, Kurt Alfred Kluever <<a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:kak@google.com">kak@google.com</a> <br>
                <a class="moz-txt-link-rfc2396E" href="mailto:kak@google.com"><mailto:kak@google.com></a>>
        wrote: <br>
                 > instant − instant = duration // what we're
        discussing <br>
                 > instant + duration = instant // satisfied by <br>
                instant.plus(duration) <br>
                 > instant - duration = instant // satisfied by <br>
                instant.minus(duration) <br>
                 > duration + duration = duration // satisfied by <br>
                duration.plus(duration) <br>
                 > duration - duration = duration // satisfied by <br>
                duration.minus(duration) <br>
                 > duration × real number = duration // satisfied by
        <br>
                duration.multipliedBy(long) <br>
                 > duration ÷ real number = duration // satisfied by
        <br>
                duration.dividedBy(long) <br>
                 > <br>
                 > All but the first operation have very clear
        translations from <br>
                conceptual model to code. I'm hoping we can achieve the
        same <br>
                clarity for instant - instant by using the obvious name:
        <br>
                instant.minus(instant) <br>
        <br>
                But you can't have <br>
                  instant + instant = ??? <br>
                It doesn't make sense. <br>
        <br>
                This is at the heart of why minus isn't right in this
        case. <br>
                Stephen <br>
        <br>
        <br>
        <br>
            --     Louis Wasserman (he/they) <br>
        <br>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>