Struct whatwg_datetime::TimeZoneOffset
source · pub struct TimeZoneOffset { /* private fields */ }
Expand description
A time-zone offset, with a signed number of hours and minutes.
Examples
use whatwg_datetime::{parse_timezone_offset, TimeZoneOffset};
assert_eq!(parse_timezone_offset("-07:00"), TimeZoneOffset::new_opt(-7, 0));
Implementations§
source§impl TimeZoneOffset
impl TimeZoneOffset
sourcepub fn new_opt(hours: i32, minutes: i32) -> Option<Self>
pub fn new_opt(hours: i32, minutes: i32) -> Option<Self>
Creates a new TimeZoneOffset
from a signed number of hours and minutes.
This asserts that:
- hours are in between -23 and 23, inclusive,
- minutes are in between 0 and 59, inclusive
Examples
use whatwg_datetime::TimeZoneOffset;
assert!(TimeZoneOffset::new_opt(-7, 0).is_some());
assert!(TimeZoneOffset::new_opt(23, 59).is_some());
assert!(TimeZoneOffset::new_opt(24, 0).is_none()); // Hours must be between [-23, 23]
assert!(TimeZoneOffset::new_opt(1, 60).is_none()); // Minutes must be between [0, 59]
Trait Implementations§
source§impl Clone for TimeZoneOffset
impl Clone for TimeZoneOffset
source§fn clone(&self) -> TimeZoneOffset
fn clone(&self) -> TimeZoneOffset
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TimeZoneOffset
impl Debug for TimeZoneOffset
source§impl PartialEq<TimeZoneOffset> for TimeZoneOffset
impl PartialEq<TimeZoneOffset> for TimeZoneOffset
source§fn eq(&self, other: &TimeZoneOffset) -> bool
fn eq(&self, other: &TimeZoneOffset) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for TimeZoneOffset
impl Eq for TimeZoneOffset
impl StructuralEq for TimeZoneOffset
impl StructuralPartialEq for TimeZoneOffset
Auto Trait Implementations§
impl RefUnwindSafe for TimeZoneOffset
impl Send for TimeZoneOffset
impl Sync for TimeZoneOffset
impl Unpin for TimeZoneOffset
impl UnwindSafe for TimeZoneOffset
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more