/home/a220/proj/radnelac/src/main.rs
Line | Count | Source |
1 | | // This Source Code Form is subject to the terms of the Mozilla Public |
2 | | // License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | | // file, You can obtain one at https://mozilla.org/MPL/2.0/. |
4 | | |
5 | | use radnelac::calendar::Armenian; |
6 | | use radnelac::calendar::Coptic; |
7 | | use radnelac::calendar::Cotsworth; |
8 | | use radnelac::calendar::Egyptian; |
9 | | use radnelac::calendar::Ethiopic; |
10 | | use radnelac::calendar::FrenchRevArith; |
11 | | use radnelac::calendar::Gregorian; |
12 | | use radnelac::calendar::Holocene; |
13 | | use radnelac::calendar::Julian; |
14 | | use radnelac::calendar::Olympiad; |
15 | | use radnelac::calendar::Positivist; |
16 | | use radnelac::calendar::Roman; |
17 | | use radnelac::calendar::Symmetry010; |
18 | | use radnelac::calendar::Symmetry010Solstice; |
19 | | use radnelac::calendar::Symmetry454; |
20 | | use radnelac::calendar::Symmetry454Solstice; |
21 | | use radnelac::calendar::TranquilityMoment; |
22 | | use radnelac::calendar::ISO; |
23 | | use radnelac::clock::TimeOfDay; |
24 | | use radnelac::day_count::BoundedDayCount; |
25 | | use radnelac::day_count::EffectiveBound; |
26 | | use radnelac::day_count::Fixed; |
27 | | use radnelac::day_count::FromFixed; |
28 | | use radnelac::day_count::JulianDay; |
29 | | use radnelac::day_count::ModifiedJulianDay; |
30 | | use radnelac::day_count::RataDie; |
31 | | use radnelac::day_count::ToFixed; |
32 | | use radnelac::day_count::UnixMoment; |
33 | | use radnelac::day_cycle::Akan; |
34 | | use radnelac::day_cycle::Weekday; |
35 | | use std::time::{SystemTime, UNIX_EPOCH}; |
36 | | |
37 | 0 | fn main() { |
38 | 0 | println!("Today is:"); |
39 | 0 | print_today(); |
40 | 0 | println!("\n\n"); |
41 | 0 | println!("Effective Minimum is:"); |
42 | 0 | print_t(Fixed::effective_min()); |
43 | 0 | println!("\n\n"); |
44 | 0 | println!("Effective Maximum is:"); |
45 | 0 | print_t(Fixed::effective_max()); |
46 | 0 | } |
47 | | |
48 | 0 | fn print_today() { |
49 | 0 | let t_system = match SystemTime::now().duration_since(UNIX_EPOCH) { |
50 | 0 | Ok(n) => n.as_secs(), |
51 | 0 | Err(_) => panic!("SystemTime before UNIX_EPOCH"), |
52 | | }; |
53 | 0 | let t_unix = UnixMoment::new(t_system as i64); |
54 | 0 | let t_fixed = t_unix.to_fixed(); |
55 | 0 | print_t(t_fixed); |
56 | 0 | } |
57 | | |
58 | | #[cfg(not(feature = "display"))] |
59 | | fn print_t(t_fixed: Fixed) { |
60 | | let m_clk = TimeOfDay::from_fixed(t_fixed); |
61 | | let t_unix = UnixMoment::from_fixed(t_fixed); |
62 | | let t_jd = JulianDay::from_fixed(t_fixed); |
63 | | let t_mjd = ModifiedJulianDay::from_fixed(t_fixed); |
64 | | let t_rd = RataDie::from_fixed(t_fixed); |
65 | | let w_week = Weekday::from_fixed(t_fixed); |
66 | | let w_akan = Akan::from_fixed(t_fixed); |
67 | | let d_egyptian = Egyptian::from_fixed(t_fixed); |
68 | | let d_armenian = Armenian::from_fixed(t_fixed); |
69 | | let d_gregorian = Gregorian::from_fixed(t_fixed); |
70 | | let d_julian = Julian::from_fixed(t_fixed); |
71 | | let d_roman = Roman::from_fixed(t_fixed); |
72 | | let d_coptic = Coptic::from_fixed(t_fixed); |
73 | | let d_ethiopic = Ethiopic::from_fixed(t_fixed); |
74 | | let d_iso = ISO::from_fixed(t_fixed); |
75 | | let d_holocene = Holocene::from_fixed(t_fixed); |
76 | | let d_french0 = FrenchRevArith::<true>::from_fixed(t_fixed); |
77 | | let d_french1 = FrenchRevArith::<false>::from_fixed(t_fixed); |
78 | | let d_positivist = Positivist::from_fixed(t_fixed); |
79 | | let d_cotsworth = Cotsworth::from_fixed(t_fixed); |
80 | | let d_symmetry454 = Symmetry454::from_fixed(t_fixed); |
81 | | let d_symmetry010 = Symmetry010::from_fixed(t_fixed); |
82 | | let d_symmetry454s = Symmetry454Solstice::from_fixed(t_fixed); |
83 | | let d_symmetry010s = Symmetry010Solstice::from_fixed(t_fixed); |
84 | | let d_tranquility = TranquilityMoment::from_fixed(t_fixed); |
85 | | let y_roman = Roman::auc_year_from_julian(d_julian.nz_year()); |
86 | | let y_olympiad = Olympiad::from_julian_year(d_julian.nz_year()); |
87 | | |
88 | | println!("{:?}", m_clk); |
89 | | println!("{:?}", t_unix); |
90 | | println!("{:?}", t_jd); |
91 | | println!("{:?}", t_mjd); |
92 | | println!("{:?}", t_rd); |
93 | | println!("{:?}", w_week); |
94 | | println!("{:?}", w_akan); |
95 | | println!("{:?}", d_egyptian); |
96 | | println!("{:?}", d_armenian); |
97 | | println!("{:?}", d_gregorian); |
98 | | println!("{:?}", d_julian); |
99 | | println!("{:?}", d_coptic); |
100 | | println!("{:?}", d_ethiopic); |
101 | | println!("{:?}", d_roman); |
102 | | println!("{:?}", d_iso); |
103 | | println!("{:?}", d_holocene); |
104 | | println!("{:?} mode: {:?}", d_french0, d_french0.is_adjusted()); |
105 | | println!("{:?} mode: {:?}", d_french1, d_french1.is_adjusted()); |
106 | | println!("{:?}", d_positivist); |
107 | | println!("{:?}", d_cotsworth); |
108 | | println!("{:?} mode: {:?}", d_symmetry454, d_symmetry454.mode()); |
109 | | println!("{:?} mode: {:?}", d_symmetry010, d_symmetry010.mode()); |
110 | | println!("{:?} mode: {:?}", d_symmetry454s, d_symmetry454s.mode()); |
111 | | println!("{:?} mode: {:?}", d_symmetry010s, d_symmetry010s.mode()); |
112 | | println!("{:?}", d_tranquility); |
113 | | println!("{:?} AUC", y_roman); |
114 | | println!("{:?}", y_olympiad); |
115 | | } |
116 | | |
117 | | #[cfg(feature = "display")] |
118 | 0 | fn print_t(t_fixed: Fixed) { |
119 | 0 | let m_clk = TimeOfDay::from_fixed(t_fixed); |
120 | 0 | let t_unix = UnixMoment::from_fixed(t_fixed); |
121 | 0 | let t_jd = JulianDay::from_fixed(t_fixed); |
122 | 0 | let t_mjd = ModifiedJulianDay::from_fixed(t_fixed); |
123 | 0 | let t_rd = RataDie::from_fixed(t_fixed); |
124 | 0 | let w_week = Weekday::from_fixed(t_fixed); |
125 | 0 | let w_akan = Akan::from_fixed(t_fixed); |
126 | 0 | let d_egyptian = Egyptian::from_fixed(t_fixed); |
127 | 0 | let d_armenian = Armenian::from_fixed(t_fixed); |
128 | 0 | let d_gregorian = Gregorian::from_fixed(t_fixed); |
129 | 0 | let d_julian = Julian::from_fixed(t_fixed); |
130 | 0 | let d_roman = Roman::from_fixed(t_fixed); |
131 | 0 | let d_coptic = Coptic::from_fixed(t_fixed); |
132 | 0 | let d_ethiopic = Ethiopic::from_fixed(t_fixed); |
133 | 0 | let d_iso = ISO::from_fixed(t_fixed); |
134 | 0 | let d_holocene = Holocene::from_fixed(t_fixed); |
135 | 0 | let d_french0 = FrenchRevArith::<true>::from_fixed(t_fixed); |
136 | 0 | let d_french1 = FrenchRevArith::<false>::from_fixed(t_fixed); |
137 | 0 | let d_positivist = Positivist::from_fixed(t_fixed); |
138 | 0 | let d_cotsworth = Cotsworth::from_fixed(t_fixed); |
139 | 0 | let d_symmetry454 = Symmetry454::from_fixed(t_fixed); |
140 | 0 | let d_symmetry010 = Symmetry010::from_fixed(t_fixed); |
141 | 0 | let d_symmetry454s = Symmetry454Solstice::from_fixed(t_fixed); |
142 | 0 | let d_symmetry010s = Symmetry010Solstice::from_fixed(t_fixed); |
143 | 0 | let d_tranquility = TranquilityMoment::from_fixed(t_fixed); |
144 | 0 | let y_roman = Roman::auc_year_from_julian(d_julian.nz_year()); |
145 | 0 | let y_olympiad = Olympiad::from_julian_year(d_julian.nz_year()); |
146 | | |
147 | 0 | println!("{} ({:?})", m_clk, m_clk); |
148 | 0 | println!("{:?}", t_unix); |
149 | 0 | println!("{:?}", t_jd); |
150 | 0 | println!("{:?}", t_mjd); |
151 | 0 | println!("{:?}", t_rd); |
152 | 0 | println!("{} ({:?})", w_week, w_week); |
153 | 0 | println!("{} ({:?})", w_akan, w_akan); |
154 | 0 | println!("{} ({:?})", d_egyptian, d_egyptian); |
155 | 0 | println!("{} ({:?})", d_armenian, d_armenian); |
156 | 0 | println!("{} ({:?})", d_gregorian, d_gregorian); |
157 | 0 | println!("{} ({:?})", d_julian, d_julian); |
158 | 0 | println!("{} ({:?})", d_coptic, d_coptic); |
159 | 0 | println!("{} ({:?})", d_ethiopic, d_ethiopic); |
160 | 0 | println!("{} ({:?})", d_roman, d_roman); |
161 | 0 | println!("{} ({:?})", d_iso, d_iso); |
162 | 0 | println!("{} ({:?})", d_holocene, d_holocene); |
163 | 0 | println!( |
164 | 0 | "{} ({:?} mode: {:?})", |
165 | | d_french0, |
166 | | d_french0, |
167 | 0 | d_french0.is_adjusted() |
168 | | ); |
169 | 0 | println!( |
170 | 0 | "{} ({:?} mode: {:?})", |
171 | | d_french1, |
172 | | d_french1, |
173 | 0 | d_french1.is_adjusted() |
174 | | ); |
175 | 0 | println!("{} ({:?})", d_positivist, d_positivist); |
176 | 0 | println!("{} ({:?})", d_cotsworth, d_cotsworth); |
177 | 0 | println!( |
178 | 0 | "{} ({:?} mode: {:?})", |
179 | | d_symmetry454, |
180 | | d_symmetry454, |
181 | 0 | d_symmetry454.mode() |
182 | | ); |
183 | 0 | println!( |
184 | 0 | "{} ({:?} mode: {:?})", |
185 | | d_symmetry010, |
186 | | d_symmetry010, |
187 | 0 | d_symmetry010.mode() |
188 | | ); |
189 | 0 | println!( |
190 | 0 | "{} ({:?} mode: {:?})", |
191 | | d_symmetry454s, |
192 | | d_symmetry454s, |
193 | 0 | d_symmetry454s.mode() |
194 | | ); |
195 | 0 | println!( |
196 | 0 | "{} ({:?} mode: {:?})", |
197 | | d_symmetry010s, |
198 | | d_symmetry010s, |
199 | 0 | d_symmetry010s.mode() |
200 | | ); |
201 | 0 | println!("{} ({:?})", d_tranquility, d_tranquility); |
202 | 0 | println!("{:?} AUC", y_roman); |
203 | 0 | println!("{:?}", y_olympiad); |
204 | 0 | } |