Skip to content

How does ValidateTemporalUnitValue permit AUTO? #3137

@trflynn89

Description

@trflynn89

With the following script (taken from test262):

const feb20 = Temporal.PlainDate.from("2020-02-01");
const feb21 = Temporal.PlainDate.from("2021-02-01");
feb21.since(feb20, { largestUnit: "auto" });

We will end up in GetDifferenceSettings with AUTO as the largestUnit:

2. Let largestUnit be ? GetTemporalUnitValuedOption(options, "largestUnit", UNSET).
3. Perform ? ValidateTemporalUnitValue(largestUnit, unitGroup).

In ValidateTemporalUnitValue, aren't we then guaranteed to throw a RangeError?

1. If value is UNSET, return UNUSED.
2. If extraValues is present and extraValues contains value, return UNUSED.
3. Let category be the value in the “Category” column of the row of Table 21 whose “Value” column contains value.
   If there is no such row, throw a RangeError exception.

Because extraValues is not present, and Table 21 does not contain an "auto" row.

Metadata

Metadata

Assignees

No one assigned

    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