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
sourceimpl<T: TimeZone> Time<T>
impl<T: TimeZone> Time<T>
sourcepub fn new(start: DateTime<T>, step: Duration) -> Self
pub fn new(start: DateTime<T>, step: Duration) -> Self
Create a new Time
generator.
Here
-
start
is the firstDateTime
in the sequence. -
step
is theDuration
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
sourceimpl<C, T> GeneratorWithPersianRug<C> for Time<T> where
T: TimeZone + 'static,
C: Context,
impl<C, T> GeneratorWithPersianRug<C> for Time<T> where
T: TimeZone + 'static,
C: Context,
Auto Trait Implementations
impl<T> RefUnwindSafe for Time<T> where
<T as TimeZone>::Offset: RefUnwindSafe,
impl<T> Send for Time<T> where
<T as TimeZone>::Offset: Send,
impl<T> Sync for Time<T> where
<T as TimeZone>::Offset: Sync,
impl<T> Unpin for Time<T> where
<T as TimeZone>::Offset: Unpin,
impl<T> UnwindSafe for Time<T> where
<T as TimeZone>::Offset: UnwindSafe,
Blanket Implementations
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