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 CoordExt for Date
impl CoordExt for Date
type Range = RangedDuration
type Range = RangedDuration
Type of coordinate ranges.
sourcefn default_val() -> Self
fn default_val() -> Self
Generates a default Self
value.
sourcefn default_min() -> Duration
fn default_min() -> Duration
Default minimum value for a range of coordinates.
sourcefn default_max() -> Duration
fn default_max() -> Duration
Default maximum value for a range of coordinates.
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 Parseable for Date
impl Parseable for Date
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<Y> PointValExt<Date> for PolyPoints<Date, Y>
impl<Y> PointValExt<Date> for PolyPoints<Date, Y>
sourcefn val_range_processor(range: Range<Option<Date>>) -> Res<Range<Date>>
fn val_range_processor(range: Range<Option<Date>>) -> Res<Range<Date>>
Processes a range over optional bounds to yield a range proper.
sourcefn val_coord_range_processor(
range: &Range<Date>
) -> Res<Range<<Date as CoordExt>::Coord>>
fn val_coord_range_processor(
range: &Range<Date>
) -> Res<Range<<Date as CoordExt>::Coord>>
Turns a range over point values into a range over coordinates.
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
sourceimpl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: FloatComponent,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: FloatComponent,
Swp: WhitePoint,
Dwp: WhitePoint,
D: AdaptFrom<S, Swp, Dwp, T>,
sourcefn adapt_into_using<M>(self, method: M) -> D where
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> D where
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified method Read more
sourcefn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford method by default Read more
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.
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T, U> IntoColor<U> for T where
U: FromColor<T>,
impl<T, U> IntoColor<U> for T where
U: FromColor<T>,
sourcefn into_color(self) -> U
fn into_color(self) -> U
Convert into T with values clamped to the color defined bounds Read more
sourceimpl<T, U> IntoColorUnclamped<U> for T where
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for T where
U: FromColorUnclamped<T>,
sourcefn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Convert into T. The resulting color might be invalid in its color space Read more
sourceimpl<T, U> TryIntoColor<U> for T where
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for T where
U: TryFromColor<T>,
sourcefn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
Convert into T, returning ok if the color is inside of its defined
range, otherwise an OutOfBounds
error is returned which contains
the unclamped color. Read more
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.