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
This is supported 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for Time
impl Ord for Time
sourceimpl PartialEq<IntervalDT> for Time
impl PartialEq<IntervalDT> for Time
sourceimpl PartialEq<Time> for IntervalDT
impl PartialEq<Time> for IntervalDT
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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl 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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl 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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Time
impl Eq for Time
impl StructuralEq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more