1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! This module provides time interval operations for working with time in general using
//! [`chrono::DateTime`].
//!
//! You should use mainly [`TimeInterval`] which provides all time operations available.
//!
//! ```
//! use chrono::NaiveDate;
//! use vizkit::time::TimeInterval;
//!
//! // Returns `DateTime<Utc>`
//! let datetime = |year, month, day| {
//! NaiveDate::from_ymd_opt(year, month, day)
//! .and_then(|date| date.and_hms_opt(0, 0, 0))
//! .expect("invalid time values")
//! .and_utc()
//! };
//!
//! assert_eq!(
//! TimeInterval::month()
//! .every(3)
//! .range(datetime(2008, 12, 3), datetime(2010, 7, 5), 1),
//! vec![
//! datetime(2009, 1, 1),
//! datetime(2009, 4, 1),
//! datetime(2009, 7, 1),
//! datetime(2009, 10, 1),
//! datetime(2010, 1, 1),
//! datetime(2010, 4, 1),
//! datetime(2010, 7, 1),
//! ]
//! )
//! ```
pub use ;