[][src]Struct utctimestamp::TimeRange

pub struct TimeRange { /* fields omitted */ }

An iterator looping over dates given a time delta as step.

The range is either right open or right closed depending on the constructor chosen, but always left closed.

Examples:

use utctimestamp::TimeRange;
use chrono::{offset::TimeZone, Duration, Utc};

let start = Utc.ymd(2019, 4, 14).and_hms(0, 0, 0);
let end = Utc.ymd(2019, 4, 16).and_hms(0, 0, 0);
let step = Duration::hours(12);
let tr: Vec<_> = TimeRange::right_closed(start, end, step).collect();

assert_eq!(tr, vec![
    Utc.ymd(2019, 4, 14).and_hms(0, 0, 0).into(),
    Utc.ymd(2019, 4, 14).and_hms(12, 0, 0).into(),
    Utc.ymd(2019, 4, 15).and_hms(0, 0, 0).into(),
    Utc.ymd(2019, 4, 15).and_hms(12, 0, 0).into(),
    Utc.ymd(2019, 4, 16).and_hms(0, 0, 0).into(),
]);

Implementations

impl TimeRange[src]

pub fn right_closed(
    start: impl Into<UtcTimeStamp>,
    end: impl Into<UtcTimeStamp>,
    step: impl Into<TimeDelta>
) -> Self
[src]

Create a time range that includes the end date.

pub fn right_open(
    start: impl Into<UtcTimeStamp>,
    end: impl Into<UtcTimeStamp>,
    step: impl Into<TimeDelta>
) -> Self
[src]

Create a time range that excludes the end date.

Trait Implementations

impl Debug for TimeRange[src]

impl Iterator for TimeRange[src]

type Item = UtcTimeStamp

The type of the elements being iterated over.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.