Struct hourglass::Deltatime
[−]
[src]
pub struct Deltatime(_);
A delta of time used in Datetime
arithmetic.
This represents a duration in time and can be used to shift Datetime
by a specified amount of time or as a result of comparing two
Datetime
. Different types of Deltatime
can be created and
each of those types affects Datetime
differently. For example,
Deltatime::seconds(86400)
is different from Deltatime::days(1)
because a Deltatime
is dependant of the Datetime
it applies to.
Example
let utc = hourglass::Timezone::utc(); let t = utc.datetime(2015, 6, 30, 0, 0, 0, 0); let add_86400_secs = t + hourglass::Deltatime::seconds(86400); assert_eq!(add_86400_secs.date(), (2015, 6, 30)); assert_eq!(add_86400_secs.time(), (23, 59, 60, 0));
Methods
impl Deltatime
[src]
fn nanoseconds(n: i64) -> Self
Create a delta of n
nanoseconds. Possible leap seconds are
accounted for.
fn microseconds(n: i64) -> Self
Create a delta of n
microseconds. Possible leap seconds are
accounted for.
fn milliseconds(n: i64) -> Self
Create a delta of n
milliseconds. Possible leap seconds are
accounted for.
fn seconds(n: i64) -> Self
Create a delta of n
seconds. Possible leap seconds are
accounted for.
fn minutes(n: i64) -> Self
Create a delta of n
minutes. Possible leap seconds are
accounted for.
fn hours(n: i64) -> Self
Create a delta of n
hours. Possible leap seconds are accounted
for.
fn days(n: i64) -> Self
Create a delta of n
days. The time part of the shifted
Datetime
is not affected. This is a logical day, therefore,
leap seconds are ignored.
fn as_nanoseconds(&self) -> i64
Returns the total number of nanoseconds contained in this delta.
If the delta is created from Deltatime::days
, the number
of nanoseconds in a day is assumed to be 86400e9
.
fn as_microseconds(&self) -> i64
Returns the total number of microseconds contained in this delta.
If the delta is created from Deltatime::days
, the number
of microseconds in a day is assumed to be 86400e6
.
fn as_milliseconds(&self) -> i64
Returns the total number of milliseconds contained in this delta.
If the delta is created from Deltatime::days
, the number
of milliseconds in a day is assumed to be 86400e3
.
fn as_seconds(&self) -> i64
Returns the total number of seconds contained in this delta.
If the delta is created from Deltatime::days
, the number
of seconds in a day is assumed to be 86400
.
fn as_minutes(&self) -> i64
Returns the total number of minutes contained in this delta.
fn as_hours(&self) -> i64
Returns the total number of hours contained in this delta.
fn as_days(&self) -> i64
Returns the total number of days contained in this delta.
Trait Implementations
impl Debug for Deltatime
[src]
impl Copy for Deltatime
[src]
impl Clone for Deltatime
[src]
fn clone(&self) -> Deltatime
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq<Deltatime> for Deltatime
[src]
fn eq(&self, other: &Deltatime) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl Eq for Deltatime
[src]
impl PartialOrd<Deltatime> for Deltatime
[src]
fn partial_cmp(&self, other: &Deltatime) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for Deltatime
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more