Skip to content

Stage 2.7 review feedback: symmetry of CalendarDateAdd and CalendarDateUntil #55

@sffc

Description

@sffc

This issue will become moot if tc39/proposal-temporal#3136 is merged

First raised in #45 (comment)

The docs of PlainDateTime state:

This method computes the difference between the two times represented by datetime and other, optionally rounds it, and returns it as a Temporal.Duration object. If other is earlier than datetime then the resulting duration will be negative. If using the default options, adding the returned Temporal.Duration to datetime will yield other.

So in other words, the docs claim that the following code should always succeed:

let dt1 = Temporal.PlainDateTime.from("...");
let dt2 = Temporal.PlainDateTime.from("...");
let diff = dt1.until(dt2);
console.assert(dt1.add(diff).equals(dt2));

I'm not convinced that the AOs in the spec for non-Gregorian calendars are symmetrical in this way.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions