/// Whether the time zone is the unknown zone. #[diplomat::rust_link(icu::time::TimeZone::is_unknown, FnInStruct)] pubfn is_unknown(&self) -> bool { self.0.is_unknown()
}
/// Creates a time zone from a BCP-47 string. /// /// Returns the unknown time zone if the string is not a valid BCP-47 subtag. #[diplomat::rust_link(icu::time::TimeZone, Struct, compact)] #[diplomat::attr(auto, named_constructor = "from_bcp47")] #[diplomat::demo(default_constructor)] pubfn create_from_bcp47(id: &DiplomatStr) -> Box<Self> {
icu_locale_core::subtags::Subtag::try_from_utf8(id)
.map(icu_time::TimeZone)
.map(TimeZone)
.map(Box::new)
.unwrap_or(Self::unknown())
}
#[diplomat::enum_convert(icu_time::zone::TimeZoneVariant, needs_wildcard)] #[diplomat::rust_link(icu::time::zone::TimeZoneVariant, Enum)] #[non_exhaustive] #[deprecated(note = "type not needed anymore")] pubenum TimeZoneVariant { // TimeZoneVariant in Rust doesn't have a default, but it is useful to have one // here for consistent behavior. #[diplomat::attr(auto, default)]
Standard,
Daylight,
}
impl TimeZoneInfo { /// Creates a time zone for UTC (Coordinated Universal Time). #[diplomat::rust_link(icu::time::TimeZoneInfo::utc, FnInStruct)] #[diplomat::rust_link(icu::time::zone::UtcOffset::zero, FnInStruct, hidden)] #[diplomat::attr(auto, named_constructor)] pubfn utc() -> Box<TimeZoneInfo> { Box::new(icu_time::TimeZoneInfo::utc().into())
}
/// Creates a time zone info from parts. /// /// `variant` is ignored. #[diplomat::attr(auto, constructor)] #[allow(deprecated)] pubfn from_parts(
id: &TimeZone,
offset: Option<&UtcOffset>,
_variant: Option<TimeZoneVariant>,
) -> Box<TimeZoneInfo> { Box::new(Self {
id: id.0,
offset: offset.map(|o| o.0),
zone_name_timestamp: None,
})
}
#[diplomat::rust_link(icu::time::TimeZoneInfo::id, FnInStruct)] #[diplomat::attr(demo_gen, disable)] // this just returns a constructor argument #[diplomat::attr(auto, getter)] pubfn id(&self) -> Box<TimeZone> { Box::new(TimeZone(self.id))
}
/// Sets the datetime at which to interpret the time zone /// for display name lookup. /// /// Notes: /// /// - If not set, the formatting datetime is used if possible. /// - If the offset is not set, the datetime is interpreted as UTC. /// - The constraints are the same as with `ZoneNameTimestamp` in Rust. /// - Set to year 1000 or 9999 for a reference far in the past or future. #[diplomat::rust_link(icu::time::TimeZoneInfo::at_date_time_iso, FnInStruct)] #[diplomat::rust_link(icu::time::zone::ZoneNameTimestamp, Struct, compact)] #[diplomat::rust_link(
icu::time::TimeZoneInfo::with_zone_name_timestamp,
FnInStruct,
hidden
)] #[diplomat::rust_link(
icu::time::zone::ZoneNameTimestamp::from_date_time_iso,
FnInStruct,
hidden
)] #[diplomat::rust_link(
icu::time::zone::ZoneNameTimestamp::far_in_future,
FnInStruct,
hidden
)] // documented #[diplomat::rust_link(icu::time::zone::ZoneNameTimestamp::far_in_past, FnInStruct, hidden)] // documented pubfn at_date_time_iso(&self, date: &IsoDate, time: &Time) -> Box<Self> { Box::new(Self {
zone_name_timestamp: Some(
icu_time::zone::ZoneNameTimestamp::from_zoned_date_time_iso(
icu_time::ZonedDateTime {
date: date.0,
time: time.0,
zone: self.offset.unwrap_or(icu_time::zone::UtcOffset::zero()),
},
),
),
..*self
})
}
/// Sets the timestamp, in milliseconds since Unix epoch, at which to interpret the time zone /// for display name lookup. /// /// Notes: /// /// - If not set, the formatting datetime is used if possible. /// - The constraints are the same as with `ZoneNameTimestamp` in Rust. #[diplomat::rust_link(icu::time::TimeZoneInfo::with_zone_name_timestamp, FnInStruct)] #[diplomat::rust_link(
icu::time::zone::ZoneNameTimestamp::from_zoned_date_time_iso,
FnInStruct,
compact
)] #[diplomat::rust_link(icu::time::zone::ZoneNameTimestamp, Struct, compact)] pubfn at_timestamp(&self, timestamp: i64) -> Box<Self> { Box::new(Self {
zone_name_timestamp: Some(
icu_time::zone::ZoneNameTimestamp::from_zoned_date_time_iso(
icu_time::ZonedDateTime::from_epoch_milliseconds_and_utc_offset(
timestamp,
icu_time::zone::UtcOffset::zero(),
),
),
),
..*self
})
}
#[diplomat::rust_link(icu::time::TimeZoneInfo::zone_name_timestamp, FnInStruct)] #[diplomat::rust_link(
icu::time::zone::ZoneNameTimestamp::to_zoned_date_time_iso,
FnInStruct,
hidden
)] #[diplomat::rust_link(
icu::time::zone::ZoneNameTimestamp::to_date_time_iso,
FnInStruct,
hidden
)] #[diplomat::attr(auto, getter)] /// Returns the DateTime for the UTC zone name reference time pubfn zone_name_date_time(&self) -> Option<IsoDateTime> { let datetime = self.zone_name_timestamp?.to_zoned_date_time_iso();
Some(IsoDateTime {
date: Box::new(IsoDate(datetime.date)),
time: Box::new(Time(datetime.time)),
})
}
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.