In essence, the add()
method first gets the number of nanoseconds represented by duration
, adds it to this instant's epochNanoseconds
, and then creates a new Temporal.Instant
object from the result. Therefore, the duration must unambiguously represent a fixed amount of time.
If you want to add a calendar duration, the addition must be performed in the context of a calendar and a time zone to account for the variable lengths of months, years, and days (because of daylight saving time). In this case, convert the instant to a Temporal.ZonedDateTime
object, add the duration, and then convert the result back to an instant.
Adding a duration is equivalent to subtracting its negation.