pub struct MsTimeZone { /* private fields */ }Expand description
The zone a network reported for a subscriber: offset plus DST adjustment.
Kept as a type of its own rather than folded into CdrTimestamp because
the wire keeps them apart — the record’s timestamp carries only an offset,
while the DST field arrives in a separate information element and is often
simply absent. Merging them in the type would claim knowledge the decoder
does not have.
Implementations§
Source§impl MsTimeZone
impl MsTimeZone
Sourcepub const fn new(offset: QuarterHourOffset, dst: DstAdjustment) -> Self
pub const fn new(offset: QuarterHourOffset, dst: DstAdjustment) -> Self
A zone from a reported offset and its daylight-saving component.
Sourcepub const fn offset(self) -> QuarterHourOffset
pub const fn offset(self) -> QuarterHourOffset
The offset as reported — already including any daylight saving.
Sourcepub const fn dst(self) -> DstAdjustment
pub const fn dst(self) -> DstAdjustment
The daylight-saving component of the reported offset.
Sourcepub const fn standard_offset(self) -> Option<QuarterHourOffset>
pub const fn standard_offset(self) -> Option<QuarterHourOffset>
The zone’s standard (winter) offset — the reported offset less the DST component.
This is what identifies the zone. Two subscribers can report the same offset from different continents; their standard offsets differ.
None when subtracting the adjustment leaves the assigned range, which
means the two fields disagreed.
Sourcepub const fn is_dst(self) -> bool
pub const fn is_dst(self) -> bool
true when the reported offset includes a daylight-saving adjustment.
Sourcepub const fn is_same_zone_across_transition(self, other: Self) -> bool
pub const fn is_same_zone_across_transition(self, other: Self) -> bool
true when both zones share a standard offset while their reported
offsets differ — the signature of a session that crossed a daylight
saving transition rather than one that moved between zones.
use mediation::{DstAdjustment, MsTimeZone, QuarterHourOffset};
let winter = MsTimeZone::new(QuarterHourOffset::from_minutes(60).unwrap(), DstAdjustment::None);
let summer = MsTimeZone::new(
QuarterHourOffset::from_minutes(120).unwrap(),
DstAdjustment::PlusOneHour,
);
assert!(winter.is_same_zone_across_transition(summer));
// A move from Berlin winter to Athens winter is not a transition.
let athens = MsTimeZone::new(QuarterHourOffset::from_minutes(120).unwrap(), DstAdjustment::None);
assert!(!winter.is_same_zone_across_transition(athens));