Struct serde_lvm::Time
[−]
[src]
#[must_use]pub struct Time(_);
Timezone-dependent time
Methods
impl Time
[src]
pub fn map<__SHRINKWRAP_T, __SHRINKWRAP_F: FnMut(NaiveTime) -> __SHRINKWRAP_T>(
self,
f: __SHRINKWRAP_F
) -> __SHRINKWRAP_T
[src]
self,
f: __SHRINKWRAP_F
) -> __SHRINKWRAP_T
Map a function over the wrapped value, consuming it in the process.
pub fn map_ref<__SHRINKWRAP_T, __SHRINKWRAP_F: FnMut(&NaiveTime) -> __SHRINKWRAP_T>(
&self,
f: __SHRINKWRAP_F
) -> __SHRINKWRAP_T
[src]
&self,
f: __SHRINKWRAP_F
) -> __SHRINKWRAP_T
Map a function over the wrapped value without consuming it.
Methods from Deref<Target = NaiveTime>
pub fn overflowing_add_signed(&self, rhs: Duration) -> (NaiveTime, i64)
[src]
Adds given Duration
to the current time,
and also returns the number of seconds
in the integral number of days ignored from the addition.
(We cannot return Duration
because it is subject to overflow or underflow.)
Example
use chrono::NaiveTime; use time::Duration; let from_hms = NaiveTime::from_hms; assert_eq!(from_hms(3, 4, 5).overflowing_add_signed(Duration::hours(11)), (from_hms(14, 4, 5), 0)); assert_eq!(from_hms(3, 4, 5).overflowing_add_signed(Duration::hours(23)), (from_hms(2, 4, 5), 86_400)); assert_eq!(from_hms(3, 4, 5).overflowing_add_signed(Duration::hours(-7)), (from_hms(20, 4, 5), -86_400));
pub fn overflowing_sub_signed(&self, rhs: Duration) -> (NaiveTime, i64)
[src]
Subtracts given Duration
from the current time,
and also returns the number of seconds
in the integral number of days ignored from the subtraction.
(We cannot return Duration
because it is subject to overflow or underflow.)
Example
use chrono::NaiveTime; use time::Duration; let from_hms = NaiveTime::from_hms; assert_eq!(from_hms(3, 4, 5).overflowing_sub_signed(Duration::hours(2)), (from_hms(1, 4, 5), 0)); assert_eq!(from_hms(3, 4, 5).overflowing_sub_signed(Duration::hours(17)), (from_hms(10, 4, 5), 86_400)); assert_eq!(from_hms(3, 4, 5).overflowing_sub_signed(Duration::hours(-22)), (from_hms(1, 4, 5), -86_400));
pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat<I> where
I: Iterator<Item = Item<'a>> + Clone,
[src]
I: Iterator<Item = Item<'a>> + Clone,
Formats the time with the specified formatting items.
Otherwise it is same to the ordinary format
method.
The Iterator
of items should be Clone
able,
since the resulting DelayedFormat
value may be formatted multiple times.
Example
use chrono::NaiveTime; use chrono::format::strftime::StrftimeItems; let fmt = StrftimeItems::new("%H:%M:%S"); let t = NaiveTime::from_hms(23, 56, 4); assert_eq!(t.format_with_items(fmt.clone()).to_string(), "23:56:04"); assert_eq!(t.format("%H:%M:%S").to_string(), "23:56:04");
The resulting DelayedFormat
can be formatted directly via the Display
trait.
assert_eq!(format!("{}", t.format_with_items(fmt)), "23:56:04");
pub fn format(&self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>>
[src]
Formats the time with the specified format string.
See the format::strftime
module
on the supported escape sequences.
This returns a DelayedFormat
,
which gets converted to a string only when actual formatting happens.
You may use the to_string
method to get a String
,
or just feed it into print!
and other formatting macros.
(In this way it avoids the redundant memory allocation.)
A wrong format string does not issue an error immediately.
Rather, converting or formatting the DelayedFormat
fails.
You are recommended to immediately use DelayedFormat
for this reason.
Example
use chrono::NaiveTime; let t = NaiveTime::from_hms_nano(23, 56, 4, 12_345_678); assert_eq!(t.format("%H:%M:%S").to_string(), "23:56:04"); assert_eq!(t.format("%H:%M:%S%.6f").to_string(), "23:56:04.012345"); assert_eq!(t.format("%-I:%M %p").to_string(), "11:56 PM");
The resulting DelayedFormat
can be formatted directly via the Display
trait.
assert_eq!(format!("{}", t.format("%H:%M:%S")), "23:56:04"); assert_eq!(format!("{}", t.format("%H:%M:%S%.6f")), "23:56:04.012345"); assert_eq!(format!("{}", t.format("%-I:%M %p")), "11:56 PM");
Trait Implementations
impl Clone for Time
[src]
fn clone(&self) -> Time
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for Time
[src]
impl Debug for Time
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Eq for Time
[src]
impl From<NaiveTime> for Time
[src]
impl From<Time> for NaiveTime
[src]
impl Ord for Time
[src]
fn cmp(&self, __arg_0: &Time) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl PartialEq for Time
[src]
fn eq(&self, __arg_0: &Time) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Time) -> bool
[src]
This method tests for !=
.
impl PartialOrd for Time
[src]
fn partial_cmp(&self, __arg_0: &Time) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Time) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Time) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Time) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Time) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Deref for Time
[src]
type Target = NaiveTime
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
Dereferences the value.
impl Borrow<NaiveTime> for Time
[src]
impl AsRef<NaiveTime> for Time
[src]
impl Display for Time
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more
impl FromStr for Time
[src]
type Err = ParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
Parses a string s
to return a value of this type. Read more
impl<'de> Deserialize<'de> for Time
[src]
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Time, D::Error>
[src]
Deserialize this value from the given Serde deserializer. Read more