Skip to content

MonthDay, YearMonth, and Time should all support parsing from time #385

Closed
@Manishearth

Description

@Manishearth

TLDR: Temporal.PlainMonthDay.from("2025-06-01") should work.

https://tc39.es/proposal-temporal/#prod-TemporalMonthDayString

When we parse a PlainMonthDay from a string, it is allowed to be specified as either an AnnotatedMonthDay or an AnnotatedDateTime[~Zoned][~TimeRequired]. It's similar for PlainTime and PlainYearMonth.

Currently we dispatch to individual parse functions:

temporal/src/parsers.rs

Lines 690 to 695 in dc36a5b

let mut record = match variant {
ParseVariant::YearMonth => parser.parse_year_month_with_annotation_handler(handler),
ParseVariant::MonthDay => parser.parse_month_day_with_annotation_handler(handler),
ParseVariant::DateTime => parser.parse_with_annotation_handler(handler),
ParseVariant::Time => parser.parse_time_with_annotation_handler(handler),
}

This is incorrect. We could probably unconditionally attempt to parse a date_time here and fall back to month_day/time/etc where necessary, but I don't know how to handle the TimeRequired/etc stuff here. Do we just check the parse result?

Metadata

Metadata

Assignees

No one assigned

    Labels

    test262Issue related to test262 conformance

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions