pub struct Time(/* private fields */);
Expand description
Time represents a valid time of day.
Implementations§
Source§impl Time
impl Time
Sourcepub const unsafe fn from_hms_unchecked(
hour: u32,
minute: u32,
sec: u32,
usec: u32,
) -> Time
pub const unsafe fn from_hms_unchecked( hour: u32, minute: u32, sec: u32, usec: u32, ) -> Time
Creates a Time
from the given hour, minute, second and microsecond.
§Safety
This function is unsafe because the values are not checked for validity! Before using it, check that the values are all correct.
Sourcepub const fn try_from_hms(
hour: u32,
minute: u32,
sec: u32,
usec: u32,
) -> Result<Time, Error>
pub const fn try_from_hms( hour: u32, minute: u32, sec: u32, usec: u32, ) -> Result<Time, Error>
Creates a Time
from the given hour, minute, second and microsecond.
Sourcepub const fn is_valid(hour: u32, minute: u32, sec: u32, usec: u32) -> bool
pub const fn is_valid(hour: u32, minute: u32, sec: u32, usec: u32) -> bool
Checks if the given hour, minute, second and microsecond fields are valid.
Sourcepub const unsafe fn from_usecs_unchecked(usecs: i64) -> Self
pub const unsafe fn from_usecs_unchecked(usecs: i64) -> Self
Creates a Time
from the given microseconds without checking validity.
§Safety
This function is unsafe because the microsecond value is not checked for validity! Before using it, check that the value is correct.
Sourcepub const fn try_from_usecs(usecs: i64) -> Result<Self, Error>
pub const fn try_from_usecs(usecs: i64) -> Result<Self, Error>
Creates a Time
from the given microseconds
Sourcepub const fn extract(self) -> (u32, u32, u32, u32)
pub const fn extract(self) -> (u32, u32, u32, u32)
Extracts (hour, minute, second, microsecond)
from the time.
Sourcepub fn format<S: AsRef<str>>(self, fmt: S) -> Result<impl Display, Error>
pub fn format<S: AsRef<str>>(self, fmt: S) -> Result<impl Display, Error>
Formats Time
by given format string.
Sourcepub fn parse<S1: AsRef<str>, S2: AsRef<str>>(
input: S1,
fmt: S2,
) -> Result<Self, Error>
pub fn parse<S1: AsRef<str>, S2: AsRef<str>>( input: S1, fmt: S2, ) -> Result<Self, Error>
Parses Time
from given string and format.
Sourcepub const fn sub_time(self, time: Time) -> IntervalDT
pub const fn sub_time(self, time: Time) -> IntervalDT
Time
subtracts Time
Sourcepub const fn add_interval_dt(self, interval: IntervalDT) -> Time
pub const fn add_interval_dt(self, interval: IntervalDT) -> Time
Time
adds IntervalDT
Sourcepub const fn sub_interval_dt(self, interval: IntervalDT) -> Time
pub const fn sub_interval_dt(self, interval: IntervalDT) -> Time
Time
subtracts IntervalDT
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Time
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for Time
serde
only.