Skip to content

handling of 'islamic' and 'islamic-rgsa' calendars #529

@fabon-f

Description

@fabon-f

As far as I understand, there is a consensus that Temporal doesn't accept nor do fallback for 'islamic' and 'islamic-rgsa' calendars, as specified in tc39/proposal-intl-era-monthcode#46 . But currently temporal_rs accepts these calendars, and I believe this is spec-incompliant.

let icu_locale_value = Value::try_from_utf8(&bytes.to_ascii_lowercase())
.map_err(|e| TemporalError::range().with_message(e.to_string()))?;
let algorithm = CalendarAlgorithm::try_from(&icu_locale_value)
.map_err(|e| TemporalError::range().with_message(e.to_string()))?;
let calendar_kind = match AnyCalendarKind::try_from(algorithm) {
Ok(c) => c,
// Handle `islamic` calendar idenitifier.
//
// This should be updated depending on `icu_calendar` support and
// intl-era-monthcode.
Err(()) if algorithm == CalendarAlgorithm::Hijri(None) => {
AnyCalendarKind::HijriTabularTypeIIFriday
}
Err(()) => return Err(TemporalError::range().with_message("unknown calendar")),
};
Ok(calendar_kind)

AnyCalendarKind::HijriSimulatedMecca => {
const { &AnyCalendar::HijriSimulated(HijriSimulated::new_mecca()) }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions