# [−][src]Struct hourglass::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).unwrap(); 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]

`pub fn nanoseconds(n: i64) -> Self`

[src]

Create a delta of `n`

nanoseconds. Possible leap seconds are
accounted for.

`pub fn microseconds(n: i64) -> Self`

[src]

Create a delta of `n`

microseconds. Possible leap seconds are
accounted for.

`pub fn milliseconds(n: i64) -> Self`

[src]

Create a delta of `n`

milliseconds. Possible leap seconds are
accounted for.

`pub fn seconds(n: i64) -> Self`

[src]

Create a delta of `n`

seconds. Possible leap seconds are
accounted for.

`pub fn minutes(n: i64) -> Self`

[src]

Create a delta of `n`

minutes. Possible leap seconds are
accounted for.

`pub fn hours(n: i64) -> Self`

[src]

Create a delta of `n`

hours. Possible leap seconds are accounted
for.

`pub fn days(n: i64) -> Self`

[src]

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.

`pub fn as_nanoseconds(&self) -> i64`

[src]

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`

.

`pub fn as_microseconds(&self) -> i64`

[src]

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`

.

`pub fn as_milliseconds(&self) -> i64`

[src]

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`

.

`pub fn as_seconds(&self) -> i64`

[src]

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`

.

`pub fn as_minutes(&self) -> i64`

[src]

Returns the total number of minutes contained in this delta.

`pub fn as_hours(&self) -> i64`

[src]

Returns the total number of hours contained in this delta.

`pub fn as_days(&self) -> i64`

[src]

Returns the total number of days contained in this delta.

## Trait Implementations

`impl Clone for Deltatime`

[src]

`fn clone(&self) -> Deltatime`

[src]

`fn clone_from(&mut self, source: &Self)`

1.0.0[src]

Performs copy-assignment from `source`

. Read more

`impl Ord for Deltatime`

[src]

`fn cmp(&self, other: &Self) -> Ordering`

[src]

`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

`fn clamp(self, min: Self, max: Self) -> Self`

[src]

`clamp`

)Restrict a value to a certain interval. Read more

`impl Eq for Deltatime`

[src]

`impl Copy for Deltatime`

[src]

`impl PartialOrd<Deltatime> for Deltatime`

[src]

`fn partial_cmp(&self, other: &Deltatime) -> Option<Ordering>`

[src]

```
#[must_use]
fn lt(&self, other: &Rhs) -> bool
```

1.0.0[src]

This method tests less than (for `self`

and `other`

) and is used by the `<`

operator. Read more

```
#[must_use]
fn le(&self, other: &Rhs) -> bool
```

1.0.0[src]

This method tests less than or equal to (for `self`

and `other`

) and is used by the `<=`

operator. Read more

```
#[must_use]
fn gt(&self, other: &Rhs) -> bool
```

1.0.0[src]

This method tests greater than (for `self`

and `other`

) and is used by the `>`

operator. Read more

```
#[must_use]
fn ge(&self, other: &Rhs) -> bool
```

1.0.0[src]

This method tests greater than or equal to (for `self`

and `other`

) and is used by the `>=`

operator. Read more

`impl PartialEq<Deltatime> for Deltatime`

[src]

`fn eq(&self, other: &Deltatime) -> bool`

[src]

```
#[must_use]
fn ne(&self, other: &Rhs) -> bool
```

1.0.0[src]

This method tests for `!=`

.

`impl Debug for Deltatime`

[src]

`impl Add<Deltatime> for Timespec`

[src]

`type Output = Timespec`

The resulting type after applying the `+`

operator.

`fn add(self, rhs: Deltatime) -> Self::Output`

[src]

`impl<'a> Add<Deltatime> for Datetime<'a>`

[src]

`type Output = Datetime<'a>`

The resulting type after applying the `+`

operator.

`fn add(self, rhs: Deltatime) -> Self::Output`

[src]

`impl Sub<Deltatime> for Timespec`

[src]

`type Output = Timespec`

The resulting type after applying the `-`

operator.

`fn sub(self, rhs: Deltatime) -> Self::Output`

[src]

`impl<'a> Sub<Deltatime> for Datetime<'a>`

[src]

`type Output = Datetime<'a>`

The resulting type after applying the `-`

operator.

`fn sub(self, rhs: Deltatime) -> Self::Output`

[src]

`impl Neg for Deltatime`

[src]

## Auto Trait Implementations

## Blanket Implementations

`impl<T> From<T> for T`

[src]

`impl<T, U> Into<U> for T where`

U: From<T>,

[src]

U: From<T>,

`impl<T> ToOwned for T where`

T: Clone,

[src]

T: Clone,

`type Owned = T`

The resulting type after obtaining ownership.

`fn to_owned(&self) -> T`

[src]

`fn clone_into(&self, target: &mut T)`

[src]

`impl<T, U> TryFrom<U> for T where`

U: Into<T>,

[src]

U: Into<T>,

`type Error = Infallible`

The type returned in the event of a conversion error.

`fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`

[src]

`impl<T, U> TryInto<U> for T where`

U: TryFrom<T>,

[src]

U: TryFrom<T>,

`type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

`fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`

[src]

`impl<T> BorrowMut<T> for T where`

T: ?Sized,

[src]

T: ?Sized,

`fn borrow_mut(&mut self) -> &mut T`

[src]

`impl<T> Borrow<T> for T where`

T: ?Sized,

[src]

T: ?Sized,

`impl<T> Any for T where`

T: 'static + ?Sized,

[src]

T: 'static + ?Sized,