/// Creates a new [`ZonedIsoDateTime`] from milliseconds since epoch (timestamp) and a UTC offset. /// /// Note: [`ZonedIsoDateTime`]s created with this constructor can only be formatted using localized offset zone styles. #[diplomat::rust_link(
icu::time::ZonedDateTime::from_epoch_milliseconds_and_utc_offset,
FnInStruct
)] #[diplomat::attr(all(supports = named_constructors, supports = fallible_constructors), named_constructor = "from_epoch_milliseconds_and_utc_offset")] pubfn from_epoch_milliseconds_and_utc_offset(
epoch_milliseconds: i64,
utc_offset: &UtcOffset,
) -> ZonedIsoDateTime { let zdt = icu_time::ZonedDateTime::from_epoch_milliseconds_and_utc_offset(
epoch_milliseconds,
utc_offset.0,
);
ZonedIsoDateTime {
date: Box::new(IsoDate(zdt.date)),
time: Box::new(Time(zdt.time)),
zone: Box::new(TimeZoneInfo::from(utc_offset.0)),
}
}
}
/// An ICU4X DateTime object capable of containing a date, time, and zone for any calendar. #[diplomat::rust_link(icu::time::ZonedDateTime, Struct)] #[diplomat::out] pubstruct ZonedDateTime { pub date: Box<Date>, pub time: Box<Time>, pub zone: Box<TimeZoneInfo>,
}
impl ZonedDateTime { /// Creates a new [`ZonedIsoDateTime`] from an IXDTF string. #[diplomat::rust_link(icu::time::ZonedDateTime::try_strict_from_str, FnInStruct)] #[diplomat::rust_link(icu::time::ZonedDateTime::try_strict_from_utf8, FnInStruct, hidden)] #[diplomat::attr(all(supports = named_constructors, supports = fallible_constructors), named_constructor = "strict_from_string")] pubfn strict_from_string(
v: &DiplomatStr,
calendar: &Calendar,
iana_parser: &IanaParser,
) -> Result<ZonedDateTime, Rfc9557ParseError> { let icu_time::ZonedDateTime { date, time, zone } =
icu_time::ZonedDateTime::try_strict_from_utf8(
v,
calendar.0.clone(),
iana_parser.0.as_borrowed(),
)?;
Ok(ZonedDateTime {
date: Box::new(Date(date)),
time: Box::new(Time(time)),
zone: Box::new(TimeZoneInfo::from(zone)),
})
}
/// Creates a new [`ZonedDateTime`] from an IXDTF string. #[deprecated(note = "use strict_from_string")] #[diplomat::rust_link(icu::time::ZonedDateTime::try_full_from_str, FnInStruct)] #[diplomat::rust_link(icu::time::ZonedDateTime::try_from_utf8, FnInStruct, hidden)] #[diplomat::attr(all(supports = named_constructors, supports = fallible_constructors), named_constructor = "full_from_string")] #[allow(deprecated)] pubfn full_from_string(
v: &DiplomatStr,
calendar: &Calendar,
iana_parser: &IanaParser,
_offset_calculator: &crate::unstable::variant_offset::ffi::VariantOffsetsCalculator,
) -> Result<ZonedDateTime, Rfc9557ParseError> { Self::strict_from_string(v, calendar, iana_parser)
}
/// Creates a new [`ZonedDateTime`] from a location-only IXDTF string. #[diplomat::rust_link(icu::time::ZonedDateTime::try_location_only_from_str, FnInStruct)] #[diplomat::rust_link(
icu::time::ZonedDateTime::try_location_only_from_utf8,
FnInStruct,
hidden
)] #[diplomat::attr(all(supports = named_constructors, supports = fallible_constructors), named_constructor = "location_only_from_string")] pubfn location_only_from_string(
v: &DiplomatStr,
calendar: &Calendar,
iana_parser: &IanaParser,
) -> Result<ZonedDateTime, Rfc9557ParseError> { let icu_time::ZonedDateTime { date, time, zone } =
icu_time::ZonedDateTime::try_location_only_from_utf8(
v,
calendar.0.clone(),
iana_parser.0.as_borrowed(),
)?;
Ok(ZonedDateTime {
date: Box::new(Date(date)),
time: Box::new(Time(time)),
zone: Box::new(TimeZoneInfo::from(zone)),
})
}
/// Creates a new [`ZonedDateTime`] from an offset-only IXDTF string. #[diplomat::rust_link(icu::time::ZonedDateTime::try_offset_only_from_str, FnInStruct)] #[diplomat::rust_link(
icu::time::ZonedDateTime::try_offset_only_from_utf8,
FnInStruct,
hidden
)] #[diplomat::attr(all(supports = named_constructors, supports = fallible_constructors), named_constructor = "offset_only_from_string")] pubfn offset_only_from_string(
v: &DiplomatStr,
calendar: &Calendar,
) -> Result<ZonedDateTime, Rfc9557ParseError> { let icu_time::ZonedDateTime { date, time, zone } =
icu_time::ZonedDateTime::try_offset_only_from_utf8(v, calendar.0.clone())?;
Ok(ZonedDateTime {
date: Box::new(Date(date)),
time: Box::new(Time(time)),
zone: Box::new(TimeZoneInfo::from(zone)),
})
}
/// Creates a new [`ZonedDateTime`] from an IXDTF string, without requiring the offset. #[diplomat::rust_link(icu::time::ZonedDateTime::try_lenient_from_str, FnInStruct)] #[diplomat::rust_link(icu::time::ZonedDateTime::try_lenient_from_utf8, FnInStruct, hidden)] #[diplomat::attr(all(supports = named_constructors, supports = fallible_constructors), named_constructor = "lenient_from_string")] pubfn lenient_from_string(
v: &DiplomatStr,
calendar: &Calendar,
iana_parser: &IanaParser,
) -> Result<ZonedDateTime, Rfc9557ParseError> { let icu_time::ZonedDateTime { date, time, zone } =
icu_time::ZonedDateTime::try_lenient_from_utf8(
v,
calendar.0.clone(),
iana_parser.0.as_borrowed(),
)?;
Ok(ZonedDateTime {
date: Box::new(Date(date)),
time: Box::new(Time(time)),
zone: Box::new(TimeZoneInfo::from(zone)),
})
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.