pub struct Time<T: TimeZone> { /* private fields */ }
Expand description

Increasing timestamps.

Each output is a DateTime, which is separated from the previous value by a fixed Duration.

Example:

use boulder::{Generator, Time};
use chrono::{DateTime, Duration};

let mut g = Time::new(DateTime::parse_from_rfc2822("Wed, 18 May 2022 15:16:00 GMT").unwrap(), Duration::days(1));
assert_eq!(g.generate(), DateTime::parse_from_rfc2822("Wed, 18 May 2022 15:16:00 GMT").unwrap());
assert_eq!(g.generate(), DateTime::parse_from_rfc2822("Thu, 19 May 2022 15:16:00 GMT").unwrap());
assert_eq!(g.generate(), DateTime::parse_from_rfc2822("Fri, 20 May 2022 15:16:00 GMT").unwrap());

Implementations

Create a new Time generator.

Here

  • start is the first DateTime in the sequence.

  • step is the Duration separating any two adjacent times in the sequence.

Example:

use boulder::{Generator, Time};
use chrono::{DateTime, Duration};

let mut g = Time::new(
    DateTime::parse_from_rfc3339("2022-03-31T17:40:00+01:00").unwrap(),
    Duration::hours(1)
);
let t = g.generate();
assert_eq!(t, DateTime::parse_from_rfc3339("2022-03-31T17:40:00+01:00").unwrap());
let t = g.generate();
assert_eq!(t, DateTime::parse_from_rfc3339("2022-03-31T18:40:00+01:00").unwrap());
let t = g.generate();
assert_eq!(t, DateTime::parse_from_rfc3339("2022-03-31T19:40:00+01:00").unwrap());

Trait Implementations

The output type.

Make a new object. Read more

Available on crate feature persian-rug only.

The output type.

Available on crate feature persian-rug only.

Make a new object. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.