pub struct TimeOffsetAmount<'a> {
pub pos_neg: PosNeg,
pub hour: Cow<'a, str>,
pub minute: Cow<'a, str>,
}
Expand description
A positive or negative amount of hours and minutes offset from UTC.
Fields§
§pos_neg: PosNeg
Represents whether the offset is positive or negative.
hour: Cow<'a, str>
Represents the number of hours that time is offset from UTC.Must be 2 decimal digits between 0 23 inclusive.
minute: Cow<'a, str>
Represents the number of minutes that time is offset from UTC. Must be 2 decimal digits between 0 59 inclusive.
Implementations§
Source§impl<'a> TimeOffsetAmount<'a>
impl<'a> TimeOffsetAmount<'a>
Source§impl<'a> TimeOffsetAmount<'a>
impl<'a> TimeOffsetAmount<'a>
Sourcepub fn from_str<S>(
pos_neg: S,
hour: S,
minute: S,
) -> Result<TimeOffsetAmount<'a>, TOMLError>
pub fn from_str<S>( pos_neg: S, hour: S, minute: S, ) -> Result<TimeOffsetAmount<'a>, TOMLError>
Create a new TimeOffsetAmount
from string type values. Returns Ok()
on success and Err()
on failure.
§Examples
use tomllib::types::TimeOffsetAmount;
let offset = TimeOffsetAmount::from_str("-", "04", "00").unwrap();
Sourcepub fn validate(&self) -> bool
pub fn validate(&self) -> bool
Validates a created TimeOffsetAmount
.
§Examples
use tomllib::types::{TimeOffsetAmount, PosNeg};
let offset_wrong = TimeOffsetAmount{pos_neg: PosNeg::Pos, hour: "31".into(), minute: "30".into()};
let offset_right = TimeOffsetAmount{pos_neg: PosNeg::Pos, hour: "07".into(), minute: "00".into()};
assert!(!offset_wrong.validate());
assert!(offset_right.validate());
Trait Implementations§
Source§impl<'a> Clone for TimeOffsetAmount<'a>
impl<'a> Clone for TimeOffsetAmount<'a>
Source§fn clone(&self) -> TimeOffsetAmount<'a>
fn clone(&self) -> TimeOffsetAmount<'a>
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<'a> Debug for TimeOffsetAmount<'a>
impl<'a> Debug for TimeOffsetAmount<'a>
Source§impl<'a> Display for TimeOffsetAmount<'a>
impl<'a> Display for TimeOffsetAmount<'a>
Source§impl<'a> PartialEq for TimeOffsetAmount<'a>
impl<'a> PartialEq for TimeOffsetAmount<'a>
impl<'a> Eq for TimeOffsetAmount<'a>
Auto Trait Implementations§
impl<'a> Freeze for TimeOffsetAmount<'a>
impl<'a> RefUnwindSafe for TimeOffsetAmount<'a>
impl<'a> Send for TimeOffsetAmount<'a>
impl<'a> Sync for TimeOffsetAmount<'a>
impl<'a> Unpin for TimeOffsetAmount<'a>
impl<'a> UnwindSafe for TimeOffsetAmount<'a>
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