Trait chrono_tz::OffsetName
source · pub trait OffsetName {
// Required methods
fn tz_id(&self) -> &str;
fn abbreviation(&self) -> &str;
}
Expand description
Timezone offset name information.
This trait exposes display names that describe an offset in various situations.
use chrono::{Duration, Offset, TimeZone};
use chrono_tz::Europe::London;
use chrono_tz::OffsetName;
let london_time = London.ymd(2016, 2, 10).and_hms(12, 0, 0);
assert_eq!(london_time.offset().tz_id(), "Europe/London");
// London is normally on GMT
assert_eq!(london_time.offset().abbreviation(), "GMT");
let london_summer_time = London.ymd(2016, 5, 10).and_hms(12, 0, 0);
// The TZ ID remains constant year round
assert_eq!(london_summer_time.offset().tz_id(), "Europe/London");
// During the summer, this becomes British Summer Time
assert_eq!(london_summer_time.offset().abbreviation(), "BST");
Required Methods§
sourcefn abbreviation(&self) -> &str
fn abbreviation(&self) -> &str
The abbreviation to use in a longer timestamp (ex: EST)
This takes into account any special offsets that may be in effect. For example, at a given instant, the time zone with ID America/New_York may be either EST or EDT.