Struct sqldatetime::Time
source · [−]#[repr(transparent)]pub struct Time(_);Expand description
Time represents a valid time of day.
Implementations
sourceimpl 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
sourceimpl<'de> Deserialize<'de> for Time
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Time
serde only.sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
sourceimpl From<IntervalDT> for Time
impl From<IntervalDT> for Time
sourcefn from(interval: IntervalDT) -> Self
fn from(interval: IntervalDT) -> Self
sourceimpl From<Time> for IntervalDT
impl From<Time> for IntervalDT
sourceimpl Ord for Time
impl Ord for Time
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl PartialEq<IntervalDT> for Time
impl PartialEq<IntervalDT> for Time
sourcefn eq(&self, other: &IntervalDT) -> bool
fn eq(&self, other: &IntervalDT) -> bool
sourceimpl PartialOrd<IntervalDT> for Time
impl PartialOrd<IntervalDT> for Time
sourcefn partial_cmp(&self, other: &IntervalDT) -> Option<Ordering>
fn partial_cmp(&self, other: &IntervalDT) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresourceimpl PartialOrd<Time> for IntervalDT
impl PartialOrd<Time> for IntervalDT
sourcefn partial_cmp(&self, other: &Time) -> Option<Ordering>
fn partial_cmp(&self, other: &Time) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresourceimpl PartialOrd<Time> for Time
impl PartialOrd<Time> for Time
sourcefn partial_cmp(&self, other: &Time) -> Option<Ordering>
fn partial_cmp(&self, other: &Time) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more