Expand description
§use-timezone
Small time zone and fixed offset primitives for RustUse.
§Example
use use_timezone::{TimeZone, TimeZoneOffset, parse_time_zone};
let zone = parse_time_zone("America/New_York").unwrap();
let offset = TimeZoneOffset::new("UTC+05:30").unwrap();
assert!(matches!(zone, TimeZone::Iana(_)));
assert_eq!(offset.total_minutes(), 330);
assert_eq!(parse_time_zone("-0800").unwrap().to_string(), "UTC-08:00");§Scope
- Represent an IANA-shaped time zone identifier or a fixed UTC/GMT offset.
- Reuse
use-time-zone-idfor IANA-shaped identifier syntax. - Parse fixed offsets such as
Z,UTC,+05:30,-0800, andGMT-08:00. - Keep fixed offsets within the civil
-14:00..=+14:00range.
§Non-goals
- Time arithmetic.
- Daylight-saving calculations.
- Date/time conversion.
- Local system time zone discovery.
- Bundled tzdb data.
- Replacement for
time,chrono, ortz-rs.
§License
Licensed under either of the following, at your option:
- Apache License, Version 2.0
- MIT license
Structs§
- Time
Zone Offset - A fixed UTC offset in signed minutes.
Enums§
- Time
Zone - A time zone represented by either an IANA-shaped identifier or a fixed offset.
- Time
Zone Parse Error - A time zone or fixed-offset parse error.
Functions§
- is_
time_ zone - Returns
truewhen the input is a valid IANA-shaped identifier or fixed offset. - is_
time_ zone_ offset - Returns
truewhen the input is a valid fixed time zone offset. - parse_
time_ zone - Parses a time zone from an IANA-shaped identifier or fixed offset.
- parse_
time_ zone_ offset - Parses a fixed time zone offset.
- try_
parse_ time_ zone - Parses a time zone from an IANA-shaped identifier or fixed offset with diagnostic errors.
- try_
parse_ time_ zone_ offset - Parses a fixed time zone offset with diagnostic errors.