pub struct TimezoneOffset(/* private fields */);Expand description
A UTC offset in hours, the wire form of the record-listing timezone knob.
The getCDR, getResellerCDR, getSMS, getMMS, getResellerSMS, and
getResellerMMS methods take a timezone parameter that VoIP.ms documents
as “adjust the times of the records according to Timezone (Numeric: -12 to
13)”. It is a whole- or fractional-hour offset from UTC, not an IANA zone
name – distinct from the getTimezones / voicemail timezone, which is a
named zone (America/New_York). Passing -5 returns timestamps in
UTC-05:00; omitting it leaves them in the account’s configured timezone.
Callers hold a chrono_tz::Tz on those methods’ timezone field; the
crate resolves it to this offset at the query’s start date via
TimezoneOffset::at before sending. Construct one directly only to bypass
zone resolution and pin a fixed numeric offset.
Wraps a Decimal constrained to -12..=13. TimezoneOffset::new
rejects out-of-range values so a nonsensical offset never reaches the wire.
§Wire format
Serializes as a bare number (-5, 5.5); deserializes tolerantly from a
JSON number or a numeric string.
Implementations§
Source§impl TimezoneOffset
impl TimezoneOffset
Sourcepub fn new(hours: impl Into<Decimal>) -> Result<Self, TimezoneOffsetError>
pub fn new(hours: impl Into<Decimal>) -> Result<Self, TimezoneOffsetError>
Construct an offset, rejecting a value outside -12..=13 hours.
Sourcepub fn at(tz: Tz, date: NaiveDate) -> Result<Self, TimezoneOffsetError>
pub fn at(tz: Tz, date: NaiveDate) -> Result<Self, TimezoneOffsetError>
The UTC offset of tz on date, the value VoIP.ms wants for a query
starting that day.
VoIP.ms takes a single numeric offset for a whole date range, but a
zone’s offset shifts across DST boundaries, so the offset is fixed at
one instant – local noon on date, chosen to sit clear of the
midnight DST fold. A zone whose offset exceeds -12..=13 (e.g.
Pacific/Kiritimati, +14) has no VoIP.ms representation and returns
TimezoneOffsetError::OutOfRange.
Trait Implementations§
Source§impl Clone for TimezoneOffset
impl Clone for TimezoneOffset
Source§fn clone(&self) -> TimezoneOffset
fn clone(&self) -> TimezoneOffset
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more