# [−][src]Struct hourglass::Deltatime

`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).unwrap();

let add_86400_secs = t + hourglass::Deltatime::seconds(86400);

## 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_from(&mut self, source: &Self)`1.0.0[src]

Performs copy-assignment from `source`. Read more

### `impl Ord for Deltatime`[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]

🔬 This is a nightly-only experimental API. (`clamp`)

Restrict a value to a certain interval. Read more

### `impl PartialOrd<Deltatime> for Deltatime`[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]

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

This method tests for `!=`.

### `impl Add<Deltatime> for Timespec`[src]

#### `type Output = Timespec`

The resulting type after applying the `+` operator.

### `impl<'a> Add<Deltatime> for Datetime<'a>`[src]

#### `type Output = Datetime<'a>`

The resulting type after applying the `+` operator.

### `impl Sub<Deltatime> for Timespec`[src]

#### `type Output = Timespec`

The resulting type after applying the `-` operator.

### `impl<'a> Sub<Deltatime> for Datetime<'a>`[src]

#### `type Output = Datetime<'a>`

The resulting type after applying the `-` operator.

### `impl Neg for Deltatime`[src]

#### `type Output = Deltatime`

The resulting type after applying the `-` operator.

## Blanket Implementations

### `impl<T> ToOwned for T where    T: Clone, `[src]

#### `type Owned = T`

The resulting type after obtaining ownership.

### `impl<T, U> TryFrom<U> for T where    U: Into<T>, `[src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

### `impl<T, U> TryInto<U> for T where    U: TryFrom<T>, `[src]

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

The type returned in the event of a conversion error.