Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 65 additions & 66 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ timezone_provider = { version = "~0.1.0", path = "./provider" }
zoneinfo_rs = { version = "~0.0.17", path = "./zoneinfo" }

# Dependencies
tinystr = { git = "https://github.com/unicode-org/icu4x", rev = "0f9fd3dd847a5a4682f7ec8a300555a7d761258c" }
icu_calendar = { git = "https://github.com/unicode-org/icu4x", rev = "0f9fd3dd847a5a4682f7ec8a300555a7d761258c", default-features = false }
icu_locale = { git = "https://github.com/unicode-org/icu4x", rev = "0f9fd3dd847a5a4682f7ec8a300555a7d761258c" }
tinystr = { git = "https://github.com/unicode-org/icu4x", rev = "5a56323558" }
icu_calendar = { git = "https://github.com/unicode-org/icu4x", rev = "5a56323558", default-features = false }
icu_locale = { git = "https://github.com/unicode-org/icu4x", rev = "5a56323558" }
rustc-hash = "2.1.0"
num-traits = { version = "0.2.19", default-features = false }
ixdtf = { git = "https://github.com/unicode-org/icu4x", rev = "0f9fd3dd847a5a4682f7ec8a300555a7d761258c" }
ixdtf = { git = "https://github.com/unicode-org/icu4x", rev = "5a56323558" }
iana-time-zone = "0.1.64"
log = "0.4.28"
tzif = "0.4.0"
jiff-tzdb = "0.1.4"
combine = "4.6.7"
web-time = "1.1.0"
zerovec = { git = "https://github.com/unicode-org/icu4x", rev = "0f9fd3dd847a5a4682f7ec8a300555a7d761258c" }
databake = { git = "https://github.com/unicode-org/icu4x", rev = "0f9fd3dd847a5a4682f7ec8a300555a7d761258c" }
zerotrie = { git = "https://github.com/unicode-org/icu4x", rev = "0f9fd3dd847a5a4682f7ec8a300555a7d761258c" }
writeable = { git = "https://github.com/unicode-org/icu4x", rev = "0f9fd3dd847a5a4682f7ec8a300555a7d761258c" }
zerovec = { git = "https://github.com/unicode-org/icu4x", rev = "5a56323558" }
databake = { git = "https://github.com/unicode-org/icu4x", rev = "5a56323558" }
zerotrie = { git = "https://github.com/unicode-org/icu4x", rev = "5a56323558" }
writeable = { git = "https://github.com/unicode-org/icu4x", rev = "5a56323558" }
zoneinfo64 = "0.2.0"

# Diplomat
Expand Down
7 changes: 3 additions & 4 deletions src/builtins/core/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ impl Calendar {
pub const HIJRI_TABULAR_THURSDAY: Self = Self::new(AnyCalendarKind::HijriTabularTypeIIThursday);
/// The Hijri Umm al-Qura calendar
pub const HIJRI_UMM_AL_QURA: Self = Self::new(AnyCalendarKind::HijriUmmAlQura);
/// The Hijri simulated calendar
pub const HIJRI_SIMULATED: Self = Self::new(AnyCalendarKind::HijriSimulatedMecca);
/// The ISO 8601 calendar
pub const ISO: Self = Self::new(AnyCalendarKind::Iso);
/// The Japanese calendar
Expand All @@ -108,7 +106,7 @@ impl Calendar {
AnyCalendarKind::Buddhist => &AnyCalendar::Buddhist(Buddhist),
AnyCalendarKind::Chinese => const { &AnyCalendar::Chinese(LunarChinese::new_china()) },
AnyCalendarKind::Coptic => &AnyCalendar::Coptic(Coptic),
AnyCalendarKind::Dangi => const { &AnyCalendar::Dangi(LunarChinese::new_dangi()) },
AnyCalendarKind::Dangi => const { &AnyCalendar::Dangi(LunarChinese::new_korea()) },
AnyCalendarKind::Ethiopian => {
const {
&AnyCalendar::Ethiopian(Ethiopian::new_with_era_style(
Expand All @@ -135,7 +133,8 @@ impl Calendar {
}
}
AnyCalendarKind::HijriSimulatedMecca => {
const { &AnyCalendar::HijriSimulated(Hijri::new_simulated_mecca()) }
// This calendar is currently unsupported by Temporal
&AnyCalendar::Iso(Iso)
}
AnyCalendarKind::HijriTabularTypeIIThursday => {
const {
Expand Down
50 changes: 23 additions & 27 deletions src/builtins/core/plain_month_day.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,34 +528,30 @@ mod tests {

#[test]
/// This test is for calendars where we don't wish to hardcode dates; but we do wish to know
/// that monthcodes can be constructed without issue
fn automated_reference_year() {
/// that monthcodes can be constructed without issue (currently only UAQ)
fn automated_uaq_reference_year() {
let reference_iso = IsoDate::new_unchecked(1972, 12, 31);
for cal in [
AnyCalendarKind::HijriSimulatedMecca,
AnyCalendarKind::HijriUmmAlQura,
] {
let calendar = Calendar::new(cal);
for month in 1..=12 {
for day in [29, 30] {
let month_code = crate::builtins::calendar::month_to_month_code(month).unwrap();

let calendar_fields = CalendarFields {
month_code: Some(month_code),
day: Some(day),
..Default::default()
};

let md = calendar
.month_day_from_fields(calendar_fields, Overflow::Reject)
.unwrap();

assert!(
md.iso <= reference_iso,
"Reference ISO for {month}-{day} must be before 1972-12-31, found, {:?}",
md.iso,
);
}

let calendar = Calendar::new(AnyCalendarKind::HijriUmmAlQura);
for month in 1..=12 {
for day in [29, 30] {
let month_code = crate::builtins::calendar::month_to_month_code(month).unwrap();

let calendar_fields = CalendarFields {
month_code: Some(month_code),
day: Some(day),
..Default::default()
};

let md = calendar
.month_day_from_fields(calendar_fields, Overflow::Reject)
.unwrap();

assert!(
md.iso <= reference_iso,
"Reference ISO for {month}-{day} must be before 1972-12-31, found, {:?}",
md.iso,
);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/parsed_intermediates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ use ixdtf::records::UtcOffsetRecordOrZ;
fn extract_kind(calendar: Option<&[u8]>) -> TemporalResult<AnyCalendarKind> {
Ok(calendar
.map(Calendar::try_kind_from_utf8)
// Note that this will successfully parse AnyCalendarKind::HijriSimulatedMecca
// However, Calendar::new will immediately turn it into an ISO calendar,
// so we don't need to do anything here.
.transpose()?
.unwrap_or(AnyCalendarKind::Iso))
}
Expand Down
15 changes: 7 additions & 8 deletions temporal_capi/bindings/c/AnyCalendarKind.d.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 14 additions & 16 deletions temporal_capi/bindings/cpp/temporal_rs/AnyCalendarKind.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion temporal_capi/bindings/cpp/temporal_rs/AnyCalendarKind.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion temporal_capi/src/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub mod ffi {
Hebrew,
Indian,
HijriTabularTypeIIFriday,
HijriSimulatedMecca,
HijriTabularTypeIIThursday,
HijriUmmAlQura,
Iso,
Expand All @@ -33,6 +32,8 @@ pub mod ffi {
let value = icu_locale::extensions::unicode::Value::try_from_utf8(s).ok()?;
let algorithm = CalendarAlgorithm::try_from(&value).ok()?;
match icu_calendar::AnyCalendarKind::try_from(algorithm) {
// islamic-rgsa / simulated-mecca is supported by ICU4X but not Temporal
Ok(icu_calendar::AnyCalendarKind::HijriSimulatedMecca) => None,
Ok(c) => Some(c.into()),
Err(()) if algorithm == CalendarAlgorithm::Hijri(None) => {
Some(Self::HijriTabularTypeIIFriday)
Expand Down