/// Get the current IANA time zone as a string. /// /// On Haiku platforms this function will return [`Some`] with the timezone string /// or [`None`] if an error occurs. On all other platforms, [`None`] is returned. /// /// # Examples /// /// ``` /// let timezone = iana_time_zone_haiku::get_timezone(); /// ``` #[must_use] pubfn get_timezone() -> Option<String> { // The longest name in the IANA time zone database is 25 ASCII characters long. letmut buf = [0u8; 32]; // SAFETY: a valid, aligned, non-NULL pointer and length are given which // point to a single allocation. let len = unsafe { let buf_size = buf.len(); let buf_ptr = buf.as_mut_ptr().cast::<c_char>();
iana_time_zone_haiku_get_tz(buf_ptr, buf_size)
}; // The name should not be empty, or excessively long. match buf.get(..len)? {
b"" => None,
s => Some(std::str::from_utf8(s).ok()?.to_owned()),
}
}
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.