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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! Date formatting
//!
//! This module includes various [`Date`] types meant for calendar day formatting:
//! ```rust
//! # use readable::date::*;
//! let date = Date::from_ymd(2020, 12, 25).unwrap();
//! let nichi = Nichi::new(2020, 12, 25).unwrap();
//!
//! assert_eq!(date, "2020-12-25");
//! assert_eq!(nichi, "Fri, Dec 25, 2020");
//! assert_eq!(date.inner(), nichi.inner());
//! ```
//!
//! The inner "integer" type is a tuple of: `(u16, u8, u8)` representing the `(Year, Month, Day)`
//!
//! - The year must be `1000-9999`
//! - The month must be `1-12`
//! - The day must be `1-31`
//!
//! ## Weekday
//! These types all have `.weekday()` functions that calculate
//! the weekday given the `year`, `month`, and `day`.
//!
//! This uses [Tomohiko Sakamoto's](https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Sakamoto's_methods) algorithm.
//!
//! It is accurate for any [`Nichi`] or [`NichiFull`]
//! but only accurate for [`Date`] when it has the `month` and `day`.
//!
//! ```rust
//! # use readable::date::*;
//! // US Independence day was on a Thursday.
//! assert_eq!(
//! Nichi::new(1776, 7, 4).unwrap().weekday().as_str(),
//! "Thursday"
//! );
//!
//! // Nintendo Switch was released on a Friday.
//! assert_eq!(
//! Nichi::new(2017, 3, 3).unwrap().weekday().as_str(),
//! "Friday"
//! );
//!
//! // Christmas in 1999 was on a Saturday.
//! assert_eq!(
//! Nichi::new(1999, 12, 25).unwrap().weekday().as_str(),
//! "Saturday"
//! );
//!
//! // A good album was released on a Wednesday.
//! assert_eq!(
//! Nichi::new(2018, 4, 25).unwrap().weekday().as_str(),
//! "Wednesday"
//! );
//! ```
//! ## From other types
//! All types support conversion with each other using [`From`],
//! although [`Date`] itself is only lossless if the full `year-month-day` is available.
//!
//! ```rust
//! # use readable::date::*;
//! // Lossless.
//! let date = Date::from_ymd(2020, 12, 25).unwrap();
//! let nichi = Nichi::from(date);
//! assert_eq!(date, (2020, 12, 25));
//! assert_eq!(nichi, (2020, 12, 25));
//!
//! // Missing date, unknown is returned.
//! let date = Date::from_ym(2020, 12).unwrap();
//! let nichi = Nichi::from(date);
//! assert_eq!(date, (2020, 12, 0));
//! assert_eq!(nichi, "???");
//! assert!(nichi.is_unknown());
//! ```
//!
//! ## Copy
//! [`Copy`] is available.
//!
//! ```rust
//! # use readable::date::*;
//! let a = Date::from_str("2014-04-22").unwrap();
//!
//! // Copy 'a', use 'b'.
//! let b = a;
//! assert_eq!(b, "2014-04-22");
//!
//! // We can still use 'a'
//! assert_eq!(a, "2014-04-22");
//! ```
pub use *;
pub use *;
pub use *;
pub
pub use *;
pub use *;