pub struct Date { /* private fields */ }
Expand description
An actual, absolute date.
As opposed to SinceStart
which represents a point in time as a duration since the start date
of the run of the program being profiled.
In practice, this type is just a wrapper around a chrono
date.
Implementations
sourceimpl Date
impl Date
sourcepub fn from_timestamp(secs: i64, nanos: u32) -> Date
pub fn from_timestamp(secs: i64, nanos: u32) -> Date
Constructor from a unix timestamp.
Examples
use base::prelude::time::*;
let (secs, subsec_nanos) = (1566489242, 7000572);
let date = Date::from_timestamp(secs, subsec_nanos);
assert_eq! { date.timestamp(), (secs, subsec_nanos) }
sourcepub fn from_micros(micros: u64) -> Date
pub fn from_micros(micros: u64) -> Date
Constructor from an ocaml duration.
Examples
use base::prelude::time::*;
let secs = 156648924_u64;
let subsec_micros = 270005_u32;
let micros = secs * 1_000_000 + (subsec_micros as u64);
let date = Date::from_micros(micros);
assert_eq! { date.timestamp(), (secs as i64, subsec_micros * 1_000) }
sourcepub fn timestamp(&self) -> (i64, u32)
pub fn timestamp(&self) -> (i64, u32)
Timestamp version of a date.
Returns a pair (
timestamp’s seconds ,
timestamp’s subsec nanoseconds )
.
Examples
use base::prelude::time::*;
let (secs, subsec_nanos) = (1_566_489_242, 7_000_572);
let date = Date::from_timestamp(secs, subsec_nanos);
assert_eq! { date.timestamp(), (secs, subsec_nanos) }
sourcepub fn time_info(&self) -> (u32, u32, u32, u32)
pub fn time_info(&self) -> (u32, u32, u32, u32)
The hours/minutes/seconds/millis of a date.
This is currently used only for debugging purposes.
Examples
use base::prelude::time::*;
let mut date = Date::from_timestamp(1566489242, 7000572);
let (_h, m, s, mi) = date.time_info();
// Can't check the hours as this depends on the local system time.
assert_eq! { m, 54 }
assert_eq! { s, 2 }
assert_eq! { mi, 7 }
Trait Implementations
sourceimpl<'a, 'b> Add<&'a SinceStart> for &'b Date
impl<'a, 'b> Add<&'a SinceStart> for &'b Date
sourcefn add(
self,
duration: &'a SinceStart
) -> <&'b Date as Add<&'a SinceStart>>::Output
fn add(
self,
duration: &'a SinceStart
) -> <&'b Date as Add<&'a SinceStart>>::Output
Performs the +
operation. Read more
sourceimpl<'a> Add<&'a SinceStart> for Date
impl<'a> Add<&'a SinceStart> for Date
sourcefn add(self, duration: &'a SinceStart) -> <Date as Add<&'a SinceStart>>::Output
fn add(self, duration: &'a SinceStart) -> <Date as Add<&'a SinceStart>>::Output
Performs the +
operation. Read more
sourceimpl<'a> Add<SinceStart> for &'a Date
impl<'a> Add<SinceStart> for &'a Date
sourcefn add(self, duration: SinceStart) -> <&'a Date as Add<SinceStart>>::Output
fn add(self, duration: SinceStart) -> <&'a Date as Add<SinceStart>>::Output
Performs the +
operation. Read more
sourceimpl Add<SinceStart> for Date
impl Add<SinceStart> for Date
Adds a duration.
Examples
use base::prelude::time::*;
let (secs, subsec_nanos) = (1_566_489_242, 7_000_572);
let mut date = Date::from_timestamp(secs, subsec_nanos);
let duration = SinceStart::parse_secs("7.003000001").unwrap();
date = date + duration;
assert_eq! { date.timestamp(), (secs + 7, subsec_nanos + 3_000_001) }
sourcefn add(self, duration: SinceStart) -> <Date as Add<SinceStart>>::Output
fn add(self, duration: SinceStart) -> <Date as Add<SinceStart>>::Output
Performs the +
operation. Read more
sourceimpl<'de> Deserialize<'de> for Date
impl<'de> Deserialize<'de> for Date
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Date, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Date, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for Date
impl Ord for Date
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Date> for Date
impl PartialOrd<Date> for Date
sourcefn partial_cmp(&self, other: &Date) -> Option<Ordering>
fn partial_cmp(&self, other: &Date) -> 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 Serialize for Date
impl Serialize for Date
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<'a> Sub<&'a SinceStart> for Date
impl<'a> Sub<&'a SinceStart> for Date
sourcefn sub(self, duration: &'a SinceStart) -> <Date as Sub<&'a SinceStart>>::Output
fn sub(self, duration: &'a SinceStart) -> <Date as Sub<&'a SinceStart>>::Output
Performs the -
operation. Read more
sourceimpl<'a, 'b> Sub<&'b SinceStart> for &'a Date
impl<'a, 'b> Sub<&'b SinceStart> for &'a Date
sourcefn sub(
self,
duration: &'b SinceStart
) -> <&'a Date as Sub<&'b SinceStart>>::Output
fn sub(
self,
duration: &'b SinceStart
) -> <&'a Date as Sub<&'b SinceStart>>::Output
Performs the -
operation. Read more
sourceimpl<'a> Sub<SinceStart> for &'a Date
impl<'a> Sub<SinceStart> for &'a Date
sourcefn sub(self, duration: SinceStart) -> <&'a Date as Sub<SinceStart>>::Output
fn sub(self, duration: SinceStart) -> <&'a Date as Sub<SinceStart>>::Output
Performs the -
operation. Read more
sourceimpl Sub<SinceStart> for Date
impl Sub<SinceStart> for Date
sourcefn sub(self, duration: SinceStart) -> <Date as Sub<SinceStart>>::Output
fn sub(self, duration: SinceStart) -> <Date as Sub<SinceStart>>::Output
Performs the -
operation. Read more
impl Copy for Date
impl Eq for Date
impl StructuralEq for Date
impl StructuralPartialEq for Date
Auto Trait Implementations
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnwindSafe for Date
Blanket Implementations
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme,
type Err = NoError
type Err = NoError
The error type produced by a failed conversion.
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
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
impl<T> ConvUtil for T
impl<T> ConvUtil for T
fn approx_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
Approximate the subject to a given type with the default scheme.
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Approximate the subject to a given type with a specific scheme.
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
impl<Src> ValueFrom<Src> for Src
impl<Src> ValueFrom<Src> for Src
type Err = NoError
type Err = NoError
The error type produced by a failed conversion.
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
Convert the given value into an exactly equivalent representation.
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>,
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>,
type Err = <Dst as ValueFrom<Src>>::Err
type Err = <Dst as ValueFrom<Src>>::Err
The error type produced by a failed conversion.
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
Convert the subject into an exactly equivalent representation.