Skip to content

Should PlainYearMonth be using month instead of monthCode when reading from instances? #2045

@justingrant

Description

@justingrant

While reviewing #2003, I noticed that PlainYearMonth is using the monthCode field instead of the month field whenever it needs to read properties of PlainYearMonth instances (e.g. in add, subtract, with, etc.).

Given that monthCode requires string creation and string parsing but month only requires numbers, will it improve performance to use month instead? For built-in calendars, I suspect that implementers can optimize the strings away but for user calendars it's an observable operation so the string usage is unavoidable. I suspect it'd also simplify implementations if the built-in path and the user-calendar path could use the same data types.

Here's the relevant pattern from the spec:

        1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"monthCode"*, *"year"* »).
        1. Let _fields_ be ? PrepareTemporalFields(_yearMonth_, _fieldNames_, «»).

@FrankYFTang do you have an opinion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    spec-textSpecification text involved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions