/home/a220/proj/radnelac/src/calendar/tranquility.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 crate::calendar::gregorian::Gregorian; |
6 | | use crate::calendar::prelude::CommonDate; |
7 | | use crate::calendar::prelude::HasLeapYears; |
8 | | use crate::calendar::prelude::OrdinalDate; |
9 | | use crate::calendar::prelude::Perennial; |
10 | | use crate::calendar::prelude::Quarter; |
11 | | use crate::calendar::prelude::ToFromCommonDate; |
12 | | use crate::calendar::prelude::ToFromOrdinalDate; |
13 | | use crate::calendar::CalendarMoment; |
14 | | use crate::calendar::HasIntercalaryDays; |
15 | | use crate::clock::ClockTime; |
16 | | use crate::clock::TimeOfDay; |
17 | | use crate::common::error::CalendarError; |
18 | | use crate::common::math::TermNum; |
19 | | use crate::day_count::BoundedDayCount; |
20 | | use crate::day_count::CalculatedBounds; |
21 | | use crate::day_count::Epoch; |
22 | | use crate::day_count::Fixed; |
23 | | use crate::day_count::FromFixed; |
24 | | use crate::day_count::ToFixed; |
25 | | use crate::day_cycle::Weekday; |
26 | | #[allow(unused_imports)] //FromPrimitive is needed for derive |
27 | | use num_traits::FromPrimitive; |
28 | | use std::cmp::Ordering; |
29 | | use std::num::NonZero; |
30 | | |
31 | | const TRANQUILITY_EPOCH_GREGORIAN: CommonDate = CommonDate { |
32 | | year: 1969, |
33 | | month: 7, |
34 | | day: 20, |
35 | | }; |
36 | | const NON_MONTH: u8 = 0; |
37 | | |
38 | | const TRANQUILITY_EPOCH_CLOCK: ClockTime = ClockTime { |
39 | | hours: 20, |
40 | | minutes: 18, |
41 | | seconds: 1.2, |
42 | | }; |
43 | | |
44 | | /// Represents a month of the Tranquility Calendar |
45 | | /// |
46 | | /// The Tranquility months are named after famous historical figures. |
47 | | /// |
48 | | /// Note that the complementary days of the Tranquility calendar year have no |
49 | | /// month and thus are not represented by TranquilityMonth. When representing an |
50 | | /// arbitrary day in the Tranquility calendar, use an `Option<TranquilityMonth>` for the |
51 | | /// the month field. |
52 | | #[derive(Debug, PartialEq, PartialOrd, Clone, Copy, FromPrimitive, ToPrimitive)] |
53 | | pub enum TranquilityMonth { |
54 | | Archimedes = 1, |
55 | | Brahe, |
56 | | Copernicus, |
57 | | Darwin, |
58 | | Einstein, |
59 | | Faraday, |
60 | | Galileo, |
61 | | Hippocrates, |
62 | | Imhotep, |
63 | | Jung, |
64 | | Kepler, |
65 | | Lavoisier, |
66 | | Mendel, |
67 | | } |
68 | | |
69 | | const AFTER_H27: i64 = (TranquilityMonth::Hippocrates as i64) * 28; |
70 | | |
71 | | /// Represents a complementary day of the Tranquility Calendar |
72 | | /// |
73 | | /// These are a bit more complex than the complementary days of the Positivist |
74 | | /// or Cotsworth calendars. |
75 | | #[derive(Debug, PartialEq, PartialOrd, Clone, Copy, FromPrimitive, ToPrimitive)] |
76 | | pub enum TranquilityComplementaryDay { |
77 | | /// This is the day of the Apollo 11 moon landing, which is the epoch for |
78 | | /// the Tranquility calendar. It is not part of any week, month or year. |
79 | | MoonLandingDay = 0, |
80 | | /// This is the last day of every year except 1 Before Tranquility. It |
81 | | /// is not part of any week or month. |
82 | | ArmstrongDay, |
83 | | /// This is an extra day added during leap years. It occurs between Hippocrates |
84 | | /// 27 and 28. It is not part of any week or month. |
85 | | AldrinDay, |
86 | | } |
87 | | |
88 | | /// Represents a date in the Tranquility Calendar |
89 | | /// |
90 | | /// ## Introduction |
91 | | /// |
92 | | /// The Tranquility calendar was proposed by Jeff Siggins in the July 1989 issue of |
93 | | /// OMNI magazine. It is used by the Orion's Arm collaborative science fiction project. |
94 | | /// Hardly anybody else uses the Tranquility calendar - it is so obscure that its Wikipedia |
95 | | /// page was deleted for lack of notability. |
96 | | /// |
97 | | /// Siggins' article starts with the following: |
98 | | /// > Are you tired of that same old calendar, with 12 months of unequal length, and dates |
99 | | /// > that always fall on different days? Do you forget lunch dates, closing days for real |
100 | | /// > estate deals, or deadlines for IRA rollovers? When plotting graphs in your fruit fly |
101 | | /// > experiment, do you ever get confused? Do you wonder why that same vile mood hits on the |
102 | | /// > fifth of one month and the fifteenth of the next? |
103 | | /// > |
104 | | /// > If these problems are yours, you are probably ready for the next step in time accounting, |
105 | | /// > the Tranquility calendar, designed for a perfection-seeking society, especially the men |
106 | | /// > and women of science. Inspired by the Apollo 11 manned mission to the moon and developed |
107 | | /// > for *Omni*, the Tranquility calendar will ease the complexity of scientific calculation, |
108 | | /// > help astronomers fathom the movements of heavenly spheres, and facilitate high-stakes business. |
109 | | /// > It will also aid everyday users who simply require a precise, easy-to-follow record of |
110 | | /// > the events of their lives. |
111 | | /// |
112 | | /// Unfortunately, despite these lofty goals, the Tranquility Calendar has many edge cases not |
113 | | /// present in other timekeeping systems; this can cause difficulty when implementing software |
114 | | /// applications. **There are almost certainly discrepancies between this library and others |
115 | | /// attempting to implement the Tranquility calendar**. |
116 | | /// |
117 | | /// ## Year 0 |
118 | | /// |
119 | | /// Year 0 is **not** supported for this calendar **except** when representing Moon Landing |
120 | | /// Day as a `CommonDate`. Technically, Moon Landing Day is not part of any week, month, or |
121 | | /// year. |
122 | | /// |
123 | | /// ## Further reading |
124 | | /// + [Orion's Arm "Encyclopaedia Galactica"](https://www.orionsarm.com/eg-article/48c6d4c3d54cf/) |
125 | | /// + [Wikipedia Deletion Log](https://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/Tranquility_Calendar) |
126 | | /// + [Archived Wikipedia article](https://web.archive.org/web/20180818233025/https://en.wikipedia.org/wiki/Tranquility_calendar) |
127 | | /// + Archived copies of Jeff Siggins' article for OMNI |
128 | | /// + [archive.org copy of mithrandir.com](https://web.archive.org/web/20161025042320/http://www.mithrandir.com/Tranquility/tranquilityArticle.html) |
129 | | /// + [archive.org copy of OMNI July 1989, pages 63, 64](https://archive.org/details/omni-archive/OMNI_1989_07/page/n63/mode/2up) |
130 | | /// + [archive.org copy of OMNI July 1989, pages 65, 66](https://archive.org/details/omni-archive/OMNI_1989_07/page/n65/mode/2up) |
131 | | #[derive(Debug, PartialEq, Clone, Copy)] |
132 | | pub struct Tranquility(CommonDate); |
133 | | |
134 | | impl Tranquility { |
135 | 8.32k | pub fn prior_elapsed_days(year: i32) -> i64 { |
136 | 8.32k | if year == 0 { |
137 | 2 | TranquilityMoment::epoch().get_day_i() - 1 |
138 | | } else { |
139 | 8.32k | let y = if year < 0 { year + 13.25k } else { year5.07k }; |
140 | 8.32k | let prior_g = Gregorian::try_from_common_date(CommonDate { |
141 | 8.32k | year: (y - 1) + TRANQUILITY_EPOCH_GREGORIAN.year, |
142 | 8.32k | month: TRANQUILITY_EPOCH_GREGORIAN.month, |
143 | 8.32k | day: TRANQUILITY_EPOCH_GREGORIAN.day, |
144 | 8.32k | }) |
145 | 8.32k | .expect("Month and day known to be valid."); |
146 | 8.32k | prior_g.to_fixed().get_day_i() |
147 | | } |
148 | 8.32k | } |
149 | | } |
150 | | |
151 | | impl ToFromOrdinalDate for Tranquility { |
152 | 1.28k | fn valid_ordinal(ord: OrdinalDate) -> Result<(), CalendarError> { |
153 | 1.28k | let correction = if TranquilityMoment::is_leap(ord.year) { |
154 | 329 | 1 |
155 | | } else { |
156 | 951 | 0 |
157 | | }; |
158 | 1.28k | if ord.day_of_year > 0 && ord.day_of_year <= (365 + correction)1.02k { |
159 | 579 | Ok(()) |
160 | | } else { |
161 | 701 | Err(CalendarError::InvalidDayOfYear) |
162 | | } |
163 | 1.28k | } |
164 | | |
165 | 15.6k | fn ordinal_from_fixed(fixed_date: Fixed) -> OrdinalDate { |
166 | | //Common |
167 | | //Gregorian: (jan1).....(feb28)(mar1).....(jul20)(jul21).....(dec31) |
168 | | //Greg ord: (1)...........(59)(60).........(201)(202).........(365) |
169 | | //Tranquility: (far25)....(hip27)(hip28)......(arm)(arc1)......(far24) |
170 | | //Tran ord: (165)........(223)(224)........(365)(1)...........(164) |
171 | | //Leap |
172 | | //Gregorian: (jan1).....(feb29)(mar1).....(jul20)(jul21).....(dec31) |
173 | | //Greg ord: (1)...........(60)(61).........(202)(203).........(366) |
174 | | //Tranquility: (far25)......(ald)(hip28)......(arm)(arc1)......(far24) |
175 | | //Tran ord: (165)........(224)(225)........(366)(1)...........(164) |
176 | | const ORDINAL_SHIFT: i64 = ((TranquilityMonth::Faraday as i64) * 28) - 4; |
177 | 15.6k | let g_ord = Gregorian::ordinal_from_fixed(fixed_date); |
178 | 15.6k | let g_doy_shift = (g_ord.day_of_year as i64) + ORDINAL_SHIFT; |
179 | 15.6k | let g_len = if Gregorian::is_leap(g_ord.year) { |
180 | 4.01k | 366 |
181 | | } else { |
182 | 11.6k | 365 |
183 | | }; |
184 | 15.6k | let tq_doy = g_doy_shift.adjusted_remainder(g_len); |
185 | 15.6k | let y_approx_0 = g_ord.year - TRANQUILITY_EPOCH_GREGORIAN.year; |
186 | 15.6k | let correct_0 = if tq_doy <= ORDINAL_SHIFT { 17.02k } else { 08.61k }; |
187 | 15.6k | let y_approx_1 = y_approx_0 + correct_0; |
188 | 15.6k | let year = if y_approx_1 < 1 { |
189 | 6.34k | y_approx_1 - 1 |
190 | | } else { |
191 | 9.28k | y_approx_1 |
192 | | }; |
193 | 15.6k | if year == -1 && tq_doy == 365136 { |
194 | 1 | OrdinalDate { |
195 | 1 | year: 0, |
196 | 1 | day_of_year: 1, |
197 | 1 | } |
198 | | } else { |
199 | 15.6k | OrdinalDate { |
200 | 15.6k | year: year, |
201 | 15.6k | day_of_year: tq_doy as u16, |
202 | 15.6k | } |
203 | | } |
204 | 15.6k | } |
205 | | |
206 | 24.9k | fn to_ordinal(self) -> OrdinalDate { |
207 | 24.9k | let comp_count = Self::complementary_count(self.0.year) as i64; |
208 | 24.9k | let ordinal_day = match self.complementary() { |
209 | 2 | Some(TranquilityComplementaryDay::MoonLandingDay) => 1, |
210 | 530 | Some(TranquilityComplementaryDay::ArmstrongDay) => 364 + comp_count, |
211 | 73 | Some(TranquilityComplementaryDay::AldrinDay) => AFTER_H27, |
212 | | None => { |
213 | 24.3k | let month = self.0.month as i64; |
214 | 24.3k | let day = self.0.day as i64; |
215 | 24.3k | let approx = ((month - 1) * 28) + day; |
216 | 24.3k | let correction = if approx < AFTER_H27 || comp_count < 29.97k { |
217 | 22.1k | 0 |
218 | | } else { |
219 | 2.25k | 1 |
220 | | }; |
221 | 24.3k | approx + correction |
222 | | } |
223 | | }; |
224 | 24.9k | OrdinalDate { |
225 | 24.9k | year: self.0.year, |
226 | 24.9k | day_of_year: ordinal_day as u16, |
227 | 24.9k | } |
228 | 24.9k | } |
229 | | |
230 | 15.3k | fn from_ordinal_unchecked(ord: OrdinalDate) -> Self { |
231 | 15.3k | let date_tq = match ( |
232 | 15.3k | ord.day_of_year as i64, |
233 | 15.3k | ord.year, |
234 | 15.3k | TranquilityMoment::is_leap(ord.year), |
235 | 15.3k | ) { |
236 | 1 | (_, 0, _) => CommonDate::new(0, NON_MONTH, 0), |
237 | 19 | (365, _, false) => CommonDate::new(ord.year, NON_MONTH, 1), |
238 | 4 | (366, _, true) => CommonDate::new(ord.year, NON_MONTH, 1), |
239 | 7 | (AFTER_H27, _, true) => CommonDate::new(ord.year, NON_MONTH, 2), |
240 | 15.3k | (doy, y, is_leap) => { |
241 | 15.3k | let correction = if doy < AFTER_H27 || !is_leap5.73k { 013.8k } else { 11.44k }; |
242 | 15.3k | let month = ((((doy - correction) - 1) as i64).div_euclid(28) + 1) as u8; |
243 | 15.3k | let day = ((doy - correction) as i64).adjusted_remainder(28) as u8; |
244 | 15.3k | debug_assert!(month > 0 && month < 14, "doy: {}, y: {}"0 , doy, y); |
245 | 15.3k | CommonDate::new(y, month, day) |
246 | | } |
247 | | }; |
248 | 15.3k | Tranquility(date_tq) |
249 | 15.3k | } |
250 | | } |
251 | | |
252 | | impl PartialOrd for Tranquility { |
253 | 7.17k | fn partial_cmp(&self, other: &Self) -> Option<Ordering> { |
254 | 7.17k | if self == other { |
255 | 4 | Some(Ordering::Equal) |
256 | | } else { |
257 | 7.17k | let self_ord = self.to_ordinal(); |
258 | 7.17k | let other_ord = other.to_ordinal(); |
259 | 7.17k | self_ord.partial_cmp(&other_ord) |
260 | | } |
261 | 7.17k | } |
262 | | } |
263 | | |
264 | | impl HasIntercalaryDays<TranquilityComplementaryDay> for Tranquility { |
265 | 39.3k | fn complementary(self) -> Option<TranquilityComplementaryDay> { |
266 | 39.3k | if self.0.month == NON_MONTH { |
267 | 899 | TranquilityComplementaryDay::from_u8(self.0.day) |
268 | | } else { |
269 | 38.4k | None |
270 | | } |
271 | 39.3k | } |
272 | | |
273 | 24.9k | fn complementary_count(p_year: i32) -> u8 { |
274 | 24.9k | if Self::is_leap(p_year) { |
275 | 5.60k | 2 |
276 | 19.3k | } else if p_year == -1 { |
277 | | //Armstrong Day replaced by Moon Landing Day |
278 | 4 | 0 |
279 | | } else { |
280 | 19.3k | 1 |
281 | | } |
282 | 24.9k | } |
283 | | } |
284 | | |
285 | | impl Perennial<TranquilityMonth, Weekday> for Tranquility { |
286 | 9.48k | fn weekday(self) -> Option<Weekday> { |
287 | 9.48k | if self.complementary().is_some() { |
288 | 14 | None |
289 | | } else { |
290 | 9.46k | Weekday::from_i64(((self.0.day as i64) + 4).modulus(7)) |
291 | | } |
292 | 9.48k | } |
293 | | |
294 | 2.55k | fn days_per_week() -> u8 { |
295 | 2.55k | 7 |
296 | 2.55k | } |
297 | | |
298 | 2.54k | fn weeks_per_month() -> u8 { |
299 | 2.54k | 4 |
300 | 2.54k | } |
301 | | } |
302 | | |
303 | | impl HasLeapYears for Tranquility { |
304 | 42.7k | fn is_leap(t_year: i32) -> bool { |
305 | 42.7k | if t_year > 0 { |
306 | 29.2k | Gregorian::is_leap(t_year + TRANQUILITY_EPOCH_GREGORIAN.year) |
307 | 13.5k | } else if t_year < 0 { |
308 | 13.5k | Gregorian::is_leap(t_year + TRANQUILITY_EPOCH_GREGORIAN.year + 1) |
309 | | } else { |
310 | 3 | false |
311 | | } |
312 | 42.7k | } |
313 | | } |
314 | | |
315 | | impl CalculatedBounds for Tranquility {} |
316 | | |
317 | | impl Epoch for Tranquility { |
318 | 2.30k | fn epoch() -> Fixed { |
319 | 2.30k | let date = Gregorian::try_from_common_date(TRANQUILITY_EPOCH_GREGORIAN) |
320 | 2.30k | .expect("Epoch known to be valid") |
321 | 2.30k | .to_fixed(); |
322 | 2.30k | let time = TimeOfDay::try_from_clock(TRANQUILITY_EPOCH_CLOCK).expect("Known valid"); |
323 | 2.30k | Fixed::new(date.get() + time.get()) |
324 | 2.30k | } |
325 | | } |
326 | | |
327 | | impl FromFixed for Tranquility { |
328 | 15.1k | fn from_fixed(date: Fixed) -> Tranquility { |
329 | 15.1k | let ord = Tranquility::ordinal_from_fixed(date); |
330 | 15.1k | Tranquility::from_ordinal_unchecked(ord) |
331 | 15.1k | } |
332 | | } |
333 | | |
334 | | impl ToFixed for Tranquility { |
335 | 8.32k | fn to_fixed(self) -> Fixed { |
336 | 8.32k | let ord = self.to_ordinal(); |
337 | 8.32k | let offset_prior = Tranquility::prior_elapsed_days(ord.year); |
338 | 8.32k | Fixed::new((offset_prior as f64) + (ord.day_of_year as f64)) |
339 | 8.32k | } |
340 | | } |
341 | | |
342 | | impl ToFromCommonDate<TranquilityMonth> for Tranquility { |
343 | 38.7k | fn to_common_date(self) -> CommonDate { |
344 | 38.7k | self.0 |
345 | 38.7k | } |
346 | | |
347 | 12.0k | fn from_common_date_unchecked(date: CommonDate) -> Self { |
348 | 12.0k | debug_assert!(Self::valid_ymd(date).is_ok()); |
349 | 12.0k | Self(date) |
350 | 12.0k | } |
351 | | |
352 | 25.3k | fn valid_ymd(date: CommonDate) -> Result<(), CalendarError> { |
353 | 25.3k | if date.month > 13 { |
354 | 512 | Err(CalendarError::InvalidMonth) |
355 | 24.8k | } else if date.month == NON_MONTH { |
356 | 2.92k | if date.day == 0 && date.year == 06 { |
357 | 6 | Ok(()) |
358 | 2.92k | } else if date.day == 1 && date.year != 02.58k && date.year != -12.58k { |
359 | 2.58k | Ok(()) |
360 | 342 | } else if date.day == 2 && date.year != 0 && Self::is_leap(date.year) { |
361 | 342 | Ok(()) |
362 | | } else { |
363 | 0 | Err(CalendarError::InvalidDay) |
364 | | } |
365 | 21.9k | } else if date.day < 1 || date.day > 2821.6k { |
366 | 512 | Err(CalendarError::InvalidDay) |
367 | 21.4k | } else if date.year == 0 { |
368 | | //Only for Moon Landing Day, as above |
369 | 0 | Err(CalendarError::InvalidYear) |
370 | | } else { |
371 | 21.4k | Ok(()) |
372 | | } |
373 | 25.3k | } |
374 | | |
375 | 257 | fn year_start_date(year: i32) -> CommonDate { |
376 | 257 | if year == 0 { |
377 | 1 | CommonDate::new( |
378 | 1 | year, |
379 | | NON_MONTH, |
380 | 1 | TranquilityComplementaryDay::MoonLandingDay as u8, |
381 | | ) |
382 | | } else { |
383 | 256 | CommonDate::new(year, 1, 1) |
384 | | } |
385 | 257 | } |
386 | | |
387 | 258 | fn year_end_date(year: i32) -> CommonDate { |
388 | 258 | if year == 0 { |
389 | 1 | CommonDate::new( |
390 | 1 | year, |
391 | | NON_MONTH, |
392 | 1 | TranquilityComplementaryDay::MoonLandingDay as u8, |
393 | | ) |
394 | 257 | } else if year == -1 { |
395 | 1 | CommonDate::new(year, TranquilityMonth::Mendel as u8, 28) |
396 | | } else { |
397 | 256 | CommonDate::new( |
398 | 256 | year, |
399 | | NON_MONTH, |
400 | 256 | TranquilityComplementaryDay::ArmstrongDay as u8, |
401 | | ) |
402 | | } |
403 | 258 | } |
404 | | } |
405 | | |
406 | | impl Quarter for Tranquility { |
407 | 2.81k | fn quarter(self) -> NonZero<u8> { |
408 | 2.81k | let m = self.to_common_date().month; |
409 | 2.81k | if m == NON_MONTH { |
410 | 2 | let d = self.to_common_date().day; |
411 | 2 | if d == 2 { |
412 | 0 | NonZero::new(3 as u8).expect("2 != 0") |
413 | | } else { |
414 | 2 | NonZero::new(4 as u8).expect("4 != 0") |
415 | | } |
416 | 2.81k | } else if m == 13 { |
417 | 288 | NonZero::new(4 as u8).expect("4 != 0") |
418 | | } else { |
419 | 2.52k | NonZero::new(((m - 1) / 3) + 1).expect("(m - 1)/3 > -1") |
420 | | } |
421 | 2.81k | } |
422 | | } |
423 | | |
424 | | /// Represents a date *and time* in the Tranquility Calendar |
425 | | pub type TranquilityMoment = CalendarMoment<Tranquility>; |
426 | | |
427 | | impl TranquilityMoment { |
428 | 512 | pub fn is_after_tranquility(self) -> bool { |
429 | 512 | if self.date().0.year == 0 { |
430 | 0 | self.time_of_day() > TRANQUILITY_EPOCH_CLOCK |
431 | | } else { |
432 | 512 | self.date().0.year > 0 |
433 | | } |
434 | 512 | } |
435 | | } |
436 | | |
437 | | #[cfg(test)] |
438 | | mod tests { |
439 | | use super::*; |
440 | | use crate::day_count::RataDie; |
441 | | |
442 | | use crate::day_count::FIXED_MAX; |
443 | | use crate::day_count::FIXED_MIN; |
444 | | |
445 | | use proptest::proptest; |
446 | | |
447 | | #[test] |
448 | 1 | fn moon_landing_edge_cases() { |
449 | 1 | let f0 = TranquilityMoment::epoch(); |
450 | 1 | let q0 = TranquilityMoment::from_fixed(f0); |
451 | 1 | let c = CommonDate::new(0, 0, 0); |
452 | 1 | assert_eq!(q0.to_common_date(), c); |
453 | 1 | let f1 = q0.to_fixed(); |
454 | 1 | assert_eq!(f0, f1); |
455 | 1 | assert_eq!(c, TranquilityMoment::year_end_date(0)); |
456 | 1 | assert_eq!(c, TranquilityMoment::year_start_date(0)); |
457 | 1 | } |
458 | | |
459 | | #[test] |
460 | 1 | fn one_bt_edge_cases() { |
461 | 1 | let c = CommonDate::new(-1, 13, 28); |
462 | 1 | assert_eq!(c, TranquilityMoment::year_end_date(-1)); |
463 | 1 | } |
464 | | |
465 | | #[test] |
466 | 1 | fn obvious_conversions_from_gregorian() { |
467 | 1 | let d_list = [ |
468 | 1 | // Moon Landing Day |
469 | 1 | (CommonDate::new(1969, 7, 20), CommonDate::new(0, 0, 0)), |
470 | 1 | // Near Moon Landing Day |
471 | 1 | (CommonDate::new(1969, 6, 30), CommonDate::new(-1, 13, 9)), |
472 | 1 | (CommonDate::new(1969, 7, 1), CommonDate::new(-1, 13, 10)), |
473 | 1 | (CommonDate::new(1969, 7, 9), CommonDate::new(-1, 13, 18)), |
474 | 1 | (CommonDate::new(1969, 7, 19), CommonDate::new(-1, 13, 28)), |
475 | 1 | (CommonDate::new(1969, 7, 21), CommonDate::new(1, 1, 1)), |
476 | 1 | (CommonDate::new(1969, 7, 31), CommonDate::new(1, 1, 11)), |
477 | 1 | (CommonDate::new(1969, 8, 1), CommonDate::new(1, 1, 12)), |
478 | 1 | // Armstrong Day |
479 | 1 | (CommonDate::new(1965, 7, 20), CommonDate::new(-5, 0, 1)), |
480 | 1 | (CommonDate::new(1968, 7, 20), CommonDate::new(-2, 0, 1)), |
481 | 1 | (CommonDate::new(1970, 7, 20), CommonDate::new(1, 0, 1)), |
482 | 1 | (CommonDate::new(1989, 7, 20), CommonDate::new(20, 0, 1)), //in Siggins' article |
483 | 1 | (CommonDate::new(1995, 7, 20), CommonDate::new(26, 0, 1)), |
484 | 1 | (CommonDate::new(1995, 7, 21), CommonDate::new(27, 1, 1)), |
485 | 1 | (CommonDate::new(2000, 7, 20), CommonDate::new(31, 0, 1)), |
486 | 1 | (CommonDate::new(2020, 7, 20), CommonDate::new(51, 0, 1)), |
487 | 1 | (CommonDate::new(2025, 7, 20), CommonDate::new(56, 0, 1)), |
488 | 1 | // Aldrin Day |
489 | 1 | (CommonDate::new(1968, 2, 29), CommonDate::new(-2, 0, 2)), |
490 | 1 | (CommonDate::new(1972, 2, 29), CommonDate::new(3, 0, 2)), |
491 | 1 | (CommonDate::new(2000, 2, 29), CommonDate::new(31, 0, 2)), |
492 | 1 | ]; |
493 | 21 | for pair20 in d_list { |
494 | 20 | let dg = Gregorian::try_from_common_date(pair.0).unwrap().to_fixed(); |
495 | 20 | let dq = TranquilityMoment::try_from_common_date(pair.1) |
496 | 20 | .unwrap() |
497 | 20 | .to_fixed(); |
498 | 20 | assert_eq!(dq.get_day_i(), dg.get_day_i()); |
499 | | } |
500 | 1 | } |
501 | | |
502 | | #[test] |
503 | 1 | fn article_examples() { |
504 | 1 | let d_list = [ |
505 | 1 | // From Siggins' article |
506 | 1 | // 21, 1, 3 |
507 | 1 | // Beginning of the Perseid meteor showers (1989) |
508 | 1 | // ??? |
509 | 1 | // Louise Brown, first test-tube baby, is born (1978) |
510 | 1 | // 1978-07-25 https://en.wikipedia.org/wiki/Louise_Brown |
511 | 1 | (CommonDate::new(1978, 7, 25), CommonDate::new(10, 1, 5)), |
512 | 1 | // NASA established and funded by Congress (1958) |
513 | 1 | // 1958-07-29 https://en.wikipedia.org/wiki/NASA |
514 | 1 | (CommonDate::new(1958, 7, 29), CommonDate::new(-11, 1, 9)), |
515 | 1 | // Explorer VI transmits first picture of Earth from space (1959) |
516 | 1 | // 1959-08-14 https://en.wikipedia.org/wiki/Explorer_6 |
517 | 1 | // (CommonDate::new(1959, 8, 14), CommonDate::new(-10, 1, 18)), //Incorrect??? |
518 | 1 | // USSR explodes its first hydrogen bomb (1953) |
519 | 1 | // 1953-08-12 https://en.wikipedia.org/wiki/RDS-6s |
520 | 1 | (CommonDate::new(1953, 8, 12), CommonDate::new(-16, 1, 23)), |
521 | 1 | // Lunar eclipse (1989) |
522 | 1 | // 1989-08-17 https://en.wikipedia.org/wiki/August_1989_lunar_eclipse |
523 | 1 | (CommonDate::new(1989, 8, 17), CommonDate::new(21, 1, 28)), |
524 | 1 | // Launch of Voyager 2, space-craft for planetary exploration (1977) |
525 | 1 | // 1977-08-20 https://en.wikipedia.org/wiki/Voyager_2 |
526 | 1 | (CommonDate::new(1977, 8, 20), CommonDate::new(9, 2, 3)), |
527 | 1 | // -1890, 2, 7 |
528 | 1 | // Pliny the Elder dies in eruption of Vesuvius at Pompeii (79) |
529 | 1 | // ??? |
530 | 1 | // Partial solar eclipse (1989) |
531 | 1 | // 1989-08-31 wiki:https://en.wikipedia.org/wiki/Solar_eclipse_of_August_31,_1989 |
532 | 1 | (CommonDate::new(1989, 8, 31), CommonDate::new(21, 2, 14)), |
533 | 1 | // Viking 2 lands near polar cap of Mars, sends photos of Earth (1976) |
534 | 1 | // 1976-09-03 wiki:https://en.wikipedia.org/wiki/Viking_2 |
535 | 1 | (CommonDate::new(1976, 9, 3), CommonDate::new(8, 2, 17)), |
536 | 1 | // Charles Darwin, in a letter to American botanist Asa Gray, propounds the law of evolution of species by means of natural selection (1857) |
537 | 1 | // 1857-09-05 wiki:https://en.wikipedia.org/wiki/Charles_Darwin |
538 | 1 | (CommonDate::new(1857, 9, 5), CommonDate::new(-112, 2, 19)), |
539 | 1 | // First privately owned rocket launched by Space Services, Inc., of the USA (1982) |
540 | 1 | // 1982-09-09 wiki:https://en.wikipedia.org/wiki/Conestoga_(rocket) |
541 | 1 | (CommonDate::new(1982, 9, 9), CommonDate::new(14, 2, 23)), |
542 | 1 | // 16, 2, 28 |
543 | 1 | // First solo balloon flight across the Atlantic Ocean embarks from Maine, arrives 86 hours later (1984) |
544 | 1 | // ??? |
545 | 1 | // Autumnal equinox. The serpent of light appears on the pyramid at Chichen Itza Mexico (1989) |
546 | 1 | // 1989-09-23 https://www.timeanddate.com/calendar/seasons.html?year=1950&n=1440 |
547 | 1 | (CommonDate::new(1989, 9, 23), CommonDate::new(21, 3, 9)), |
548 | 1 | // "Blue sun," a 200-mile-wide blanket of smoke, caused by forest fires in Alberta and British Columbia, Canada (1950) |
549 | 1 | // 1950-09-24 https://en.wikipedia.org/wiki/Chinchaga_fire (black sunday) |
550 | 1 | // (CommonDate::new(1950, 9, 24), CommonDate::new(-19, 3, 12)), //Incorrect? |
551 | 1 | // Shuttle Discovery launched, first manned US craft since the Challenger (1988) |
552 | 1 | // 1988-09-29 https://en.wikipedia.org/wiki/STS-26 |
553 | 1 | (CommonDate::new(1988, 9, 29), CommonDate::new(20, 3, 15)), |
554 | 1 | // 21, 3, 16 |
555 | 1 | // First day of year 5750 on the Judaic calendar (1989) |
556 | 1 | // ??? |
557 | 1 | // Sputnik 1, first successful man-made satellite, is launched by the USSR (1957) |
558 | 1 | // 1957-10-04 https://en.wikipedia.org/wiki/Sputnik_1 |
559 | 1 | (CommonDate::new(1957, 10, 4), CommonDate::new(-12, 3, 20)), |
560 | 1 | // -302, 3, 25 |
561 | 1 | // Antonie van Leeuwenhoek announces discovery of microorganisms (1667) |
562 | 1 | // ??? |
563 | 1 | // Christopher Columbus lands in the Bahamas (1492) |
564 | 1 | // 1492-10-12 https://en.wikipedia.org/wiki/Voyages_of_Christopher_Columbus |
565 | 1 | // (CommonDate::new(1492, 10, 2), CommonDate::new(-477, 3, 28)), //Incorrect? |
566 | 1 | // USAF Chaptain Charles Yeager becomes first human to fly faster than the speed of sound |
567 | 1 | // 1947-10-14 https://en.wikipedia.org/wiki/Bell_X-1 |
568 | 1 | // (CommonDate::new(1947, 10, 4), CommonDate::new(-22, 4, 2)), //Incorrect? |
569 | 1 | // -123, 4, 4 |
570 | 1 | // First public operation using ether as an anesthetic is performed at Massachusetts General Hospital |
571 | 1 | // ??? |
572 | 1 | // Thomas Edison invents incandescent electric lamp (1879) |
573 | 1 | // 1879-10-22 https://en.wikipedia.org/wiki/Incandescent_light_bulb |
574 | 1 | // (CommonDate::new(1879, 10, 22), CommonDate::new(-90, 4, 9)), //Incorrect? |
575 | 1 | // The first recorded parachute descent, from a balloon (1797) (1st Brumaire, Year VI of the Republican calendar) |
576 | 1 | // 1797-10-22 https://en.wikipedia.org/wiki/Andr%C3%A9-Jacques_Garnerin |
577 | 1 | (CommonDate::new(1797, 10, 22), CommonDate::new(-172, 4, 10)), |
578 | 1 | // -10, 4, 15 |
579 | 1 | // The Soviet Union releases the first pictures of the far side of the moon, taken by Lunik 3 (1959) |
580 | 1 | // ??? 1959-10-07 wiki:https://en.wikipedia.org/wiki/Luna_3 |
581 | 1 | // Laika, a Russian dog, becomes the first "higher" animal in space (1957) |
582 | 1 | // 1957-11-03 https://en.wikipedia.org/wiki/Sputnik_2 |
583 | 1 | (CommonDate::new(1957, 11, 3), CommonDate::new(-12, 4, 22)), |
584 | 1 | // Archaeologist Howard Carter discovers tomb of King Tut at Luxor, Egypt (1922) |
585 | 1 | // 1992-11-04 https://en.wikipedia.org/wiki/Discovery_of_the_tomb_of_Tutankhamun |
586 | 1 | // (CommonDate::new(1992, 11, 4), CommonDate::new(-47, 4, 23)), // Incorrect? |
587 | 1 | // 25, 4, 28 |
588 | 1 | // The next transit of the planet Mercury across the face of the sun (1993) |
589 | 1 | // ??? 1993-11-06 https://en.m.wikipedia.org/wiki/Transit_of_Mercury |
590 | 1 | // The first coast-to-coast direct-dial telephone service begins, Englewood, New Jersey (1951) |
591 | 1 | // 1951-11-10 https://en.wikipedia.org/wiki/Englewood,_New_Jersey |
592 | 1 | (CommonDate::new(1951, 11, 10), CommonDate::new(-18, 5, 1)), |
593 | 1 | // Voyager 1 nears Saturn; photos reveal three new moons (1980) |
594 | 1 | // 1980-11-12 https://en.wikipedia.org/wiki/Voyager_1 |
595 | 1 | (CommonDate::new(1980, 11, 12), CommonDate::new(12, 5, 3)), |
596 | 1 | // -3, 5, 8 |
597 | 1 | // The densest meteor shower ever recorded (1966) |
598 | 1 | // ??? |
599 | 1 | // -63, 5, 13 |
600 | 1 | // SOS adopted as the international distress call (1906) |
601 | 1 | // ??? 1906-11-03 wiki:https://en.wikipedia.org/wiki/SOS |
602 | 1 | // Charles Darwin's The Origin of Species is published (1859) |
603 | 1 | // 1859-11-24 https://en.wikipedia.org/wiki/On_the_Origin_of_Species |
604 | 1 | (CommonDate::new(1859, 11, 24), CommonDate::new(-110, 5, 15)), |
605 | 1 | // -23, 5, 28 |
606 | 1 | // Percy Spencer patents the microwave oven (1946) |
607 | 1 | // ??? 1945-10-08 wiki:https://en.wikipedia.org/wiki/Percy_Spencer |
608 | 1 | // Anethesia used for first time to perform a dental extraction (1844) |
609 | 1 | //1844-12-10 https://en.wikipedia.org/wiki/History_of_general_anesthesia |
610 | 1 | // (CommonDate::new(1844, 12, 10), CommonDate::new(-125, 6, 4)), // Incorrect?? |
611 | 1 | // -22, 6, 5 |
612 | 1 | // John Bardeen, Walter Brattain, and William Shockley invent the transistor (1947) |
613 | 1 | // ??? 1947-(11-17 to 12-23) wiki:https://en.wikipedia.org/wiki/Transistor |
614 | 1 | // The first airplane flight by Orville and Wilbur Wright, Kitty Hawk, North Carolina (1903) |
615 | 1 | //1903-12-17 https://en.wikipedia.org/wiki/Wright_Flyer |
616 | 1 | (CommonDate::new(1903, 12, 17), CommonDate::new(-66, 6, 10)), |
617 | 1 | // Winter solstice (1989) |
618 | 1 | //1989-12-21 https://aa.usno.navy.mil/calculated/seasons?year=1989&tz=0.00&tz_sign=-1&tz_label=false&dst=false&submit=Get+Data |
619 | 1 | (CommonDate::new(1989, 12, 21), CommonDate::new(21, 6, 14)), |
620 | 1 | // 6, 6, 17 |
621 | 1 | // The discovery of Lucy, fossil remains of an early female hominid, in Ethiopia (1974) |
622 | 1 | // ??? |
623 | 1 | // New Year's Day on both the Gregorian Calendar (1990) and Japanese calendar (2651) |
624 | 1 | // 1990-01-01 by definition |
625 | 1 | (CommonDate::new(1990, 1, 1), CommonDate::new(21, 6, 25)), |
626 | 1 | // 21, 6, 28 |
627 | 1 | // The earth is at its farthest distance from the sun (aphelion) (1990) |
628 | 1 | // ??? 1990-01-04 is the perihelion wiki:https://aa.usno.navy.mil/calculated/seasons?year=1990&tz=0.00&tz_sign=-1&tz_label=false&dst=false&submit=Get+Data |
629 | 1 | // Galileo discovers the moons of Jupiter (1610) |
630 | 1 | // 1610-01-07 https://en.wikipedia.org/wiki/Galileo_Galilei |
631 | 1 | (CommonDate::new(1610, 1, 7), CommonDate::new(-360, 7, 3)), |
632 | 1 | // 16, 7, 9 |
633 | 1 | // Ornithologists count 1350 great white cranes at Poyand Lake in China, the most ever recorded (1985) |
634 | 1 | // ??? |
635 | 1 | // Earthquake changes course of the Mississippi River (1812) |
636 | 1 | // 1812-01-23 https://en.wikipedia.org/wiki/1811%E2%80%931812_New_Madrid_earthquakes |
637 | 1 | (CommonDate::new(1812, 1, 23), CommonDate::new(-158, 7, 19)), |
638 | 1 | // Annular eclipse of the sun (1990) |
639 | 1 | // 1990-01-26 wiki:https://en.wikipedia.org/wiki/List_of_solar_eclipses_in_the_20th_century |
640 | 1 | (CommonDate::new(1990, 1, 26), CommonDate::new(21, 7, 22)), |
641 | 1 | // Apollo 1 fire kills US astronauts Gus Grissom, Ed White, and Roger Chaffee (1967) |
642 | 1 | //1967-01-27 https://en.wikipedia.org/wiki/Apollo_1 |
643 | 1 | (CommonDate::new(1967, 1, 27), CommonDate::new(-3, 7, 23)), |
644 | 1 | // The space shuttle Challenger explodes, killing seven American astronauts (1986) |
645 | 1 | //1986-01-28 https://en.wikipedia.org/wiki/Space_Shuttle_Challenger_disaster |
646 | 1 | (CommonDate::new(1986, 1, 28), CommonDate::new(17, 7, 24)), |
647 | 1 | // Explorer 1, the first US satellite, is launched (1958) |
648 | 1 | //1958-02-01 https://en.wikipedia.org/wiki/Explorer_1 |
649 | 1 | // (CommonDate::new(1958, 2, 1), CommonDate::new(-12, 7, 27)), //Incorrect?? |
650 | 1 | // Soviet Luna 9 makes first successful soft landing on the moon (1966) |
651 | 1 | //1966-02-03 https://en.wikipedia.org/wiki/Luna_9 |
652 | 1 | (CommonDate::new(1966, 2, 3), CommonDate::new(-4, 8, 2)), |
653 | 1 | // Two US astronauts become first humans to fly untethered in space (1984) |
654 | 1 | //1984-02-07 https://en.wikipedia.org/wiki/STS-41-B |
655 | 1 | // (CommonDate::new(1984, 2, 7), CommonDate::new(15, 8, 2)), //Incorrect?? |
656 | 1 | // Total lunar eclipse (1990) |
657 | 1 | //1990-02-09 https://en.wikipedia.org/wiki/List_of_lunar_eclipses_in_the_20th_century |
658 | 1 | // (CommonDate::new(1990, 2, 9), CommonDate::new(21, 8, 7)), //Incorrect?? |
659 | 1 | // -388, 8, 12 |
660 | 1 | // Pope Gregory corrects the Julian calendar (1582) |
661 | 1 | // ??? 1582-10-15 wiki:https://en.wikipedia.org/wiki/Gregorian_calendar |
662 | 1 | |
663 | 1 | // Italian philosopher Giordano Bruno burned at the stake for his heliocentric views (1600) |
664 | 1 | //1600-02-17 https://en.wikipedia.org/wiki/Giordano_Bruno |
665 | 1 | (CommonDate::new(1600, 2, 17), CommonDate::new(-370, 8, 16)), |
666 | 1 | // The planet Pluto is discovered by Clyde Tombaught (1930) |
667 | 1 | //1930-02-18 https://en.m.wikipedia.org/wiki/Pluto |
668 | 1 | (CommonDate::new(1930, 2, 18), CommonDate::new(-40, 8, 17)), |
669 | 1 | // John Glenn aboard the Friendship 7, becomes the first American to orbit Earth (1962) |
670 | 1 | //1962-02-20 https://en.wikipedia.org/wiki/Mercury-Atlas_6 |
671 | 1 | (CommonDate::new(1962, 2, 20), CommonDate::new(-8, 8, 19)), |
672 | 1 | // Sir James Chadwick of Great Britain announces the discovery of the neutron (1932) |
673 | 1 | //1932-02-27 https://web.mit.edu/22.54/resources/Chadwick.pdf |
674 | 1 | (CommonDate::new(1932, 2, 27), CommonDate::new(-38, 8, 26)), |
675 | 1 | // The launch of Pioneer 10, first known Earth object to leave solar system (1972) |
676 | 1 | //1972-03-03 https://en.wikipedia.org/wiki/Pioneer_10 |
677 | 1 | // (CommonDate::new(1972, 3, 3), CommonDate::new(3, 9, 1)), |
678 | 1 | // -189, 9, 5 |
679 | 1 | // Sir William Herschel discovers Uranus (1781) |
680 | 1 | // ?? 1781-03-13 wiki:https://en.wikipedia.org/wiki/Uranus |
681 | 1 | // -2013, 9, 14 |
682 | 1 | // The Ides of March, the day that Julius Caesar died (-44) |
683 | 1 | // ?? Julian -44-03-15 wiki:https://en.wikipedia.org/wiki/Julius_Caesar |
684 | 1 | // -44, 9, 15 |
685 | 1 | // Robert Goddard launches the first successful liquid-fuel rocket (1926) |
686 | 1 | // ?? |
687 | 1 | |
688 | 1 | // The US Congress authorizes conversion to standard time zones and daylight saving time (1918) |
689 | 1 | // 1918-03-29 https://en.wikipedia.org/wiki/Standard_Time_Act |
690 | 1 | // (CommonDate::new(1918, 3, 29), CommonDate::new(-12, 9, 18)), //Incorrect? |
691 | 1 | // Vernal equinox. Serpent of light appears on the pyramid at Chichen Itza, Mexico (1990) |
692 | 1 | // 1990-03-20 https://aa.usno.navy.mil/calculated/seasons?year=1990&tz=0.00&tz_sign=-1&tz_label=false&dst=false&submit=Get+Data |
693 | 1 | (CommonDate::new(1990, 3, 20), CommonDate::new(21, 9, 19)), |
694 | 1 | // Accident at Three Mile Island Nuclear Generating Station in Pennsylvania (1979) |
695 | 1 | // 1979-03-28 https://en.wikipedia.org/wiki/Three_Mile_Island_accident |
696 | 1 | (CommonDate::new(1979, 3, 28), CommonDate::new(10, 9, 27)), |
697 | 1 | // Mariner 10 spacecraft approaches Mercury and sends 647 photos back to Earth (1974) |
698 | 1 | // 1974-03-29 https://en.wikipedia.org/wiki/Mariner_10 |
699 | 1 | (CommonDate::new(1974, 3, 29), CommonDate::new(5, 9, 28)), |
700 | 1 | // Samuel Morey patents the internal-combustion engine (1826) |
701 | 1 | // 1826-04-01 https://www.ancientpages.com/2017/04/01/samuel-morey-patent/ |
702 | 1 | (CommonDate::new(1826, 4, 1), CommonDate::new(-144, 10, 3)), |
703 | 1 | // First commerical communications satellite launched (US) (1965) |
704 | 1 | // 1965-04-06 https://en.wikipedia.org/wiki/Communications_satellite |
705 | 1 | // (CommonDate::new(1965, 4, 6), CommonDate::new(-5, 10, 6)), //Incorrect? |
706 | 1 | // -61, 10, 8 |
707 | 1 | // Robert E. Peary claims discovery of the North Pole (1909) |
708 | 1 | // ?? 1909-04-06?? -07?? wiki:https://en.wikipedia.org/wiki/Robert_Peary |
709 | 1 | // Cosmonaut Yuri Gagarin of the USSR orbits Earth, becoming the first human in space (1961) |
710 | 1 | // 1961-04-12 https://en.wikipedia.org/wiki/Vostok_1 |
711 | 1 | (CommonDate::new(1961, 4, 12), CommonDate::new(-9, 10, 14)), |
712 | 1 | // 3, 10, 18 |
713 | 1 | // Two giant pandas, gifts from People's Republic of China, arrive at the National Zoo in Washington DC (1972) |
714 | 1 | // ?? |
715 | 1 | // -284, 10, 19 |
716 | 1 | // Sir Isaac Newton presents Philosophiae naturalis principia mathematica to the Royal Society (1686) |
717 | 1 | // ?? |
718 | 1 | // Francis Crick and James Watson report their discovery of the DNA double helix (1953) |
719 | 1 | //1953-04-25 wiki:https://www.nature.com/articles/171737a0 |
720 | 1 | (CommonDate::new(1953, 04, 25), CommonDate::new(-17, 10, 27)), |
721 | 1 | // Alan Shepard becomes the first American in space (1961) |
722 | 1 | //1961-05-05 wiki:https://en.wikipedia.org/wiki/Mercury-Redstone_3 |
723 | 1 | (CommonDate::new(1961, 05, 05), CommonDate::new(-9, 11, 9)), |
724 | 1 | // -174, 11, 18 |
725 | 1 | // Dr Edward Jenner conducts his first experiment with cow-pox vaccination (1796) |
726 | 1 | // ?? |
727 | 1 | // Charles Lindbergh lands in Paris, becoming the first person to fly an airplane solo, nonstop across the Atlantic Ocean (1927) |
728 | 1 | //1927-05-21 wiki:https://en.wikipedia.org/wiki/Spirit_of_St._Louis |
729 | 1 | (CommonDate::new(1927, 05, 21), CommonDate::new(-43, 11, 25)), |
730 | 1 | // The Concorde supersonic transport makes its first transatlantic flight to USA (1976) |
731 | 1 | //1976-05-24 wiki:https://en.wikipedia.org/wiki/Concorde_operational_history |
732 | 1 | (CommonDate::new(1976, 05, 24), CommonDate::new(7, 11, 28)), |
733 | 1 | // -2554, 12, 4 |
734 | 1 | // Most famous ancient solar eclipse occurs during a battle between Lydians and Medes (585 BC) |
735 | 1 | // ?? Julian -585-05-28 wiki:https://en.wikipedia.org/wiki/Eclipse_of_Thales |
736 | 1 | // US launches the Mariner 9, first spacecraft to orbit another planet (1971) |
737 | 1 | // 1971-05-30 https://en.wikipedia.org/wiki/Mariner_9 |
738 | 1 | (CommonDate::new(1971, 5, 30), CommonDate::new(2, 12, 6)), |
739 | 1 | // Guglielmo Marconi is granted patent for the radio in Great Britain (1896) |
740 | 1 | // 1896-06-02 https://en.wikipedia.org/wiki/Guglielmo_Marconi |
741 | 1 | (CommonDate::new(1896, 6, 2), CommonDate::new(-74, 12, 9)), |
742 | 1 | // Byron Allen pedals Gossamer Albatross aircraft across the English Channel (1979) |
743 | 1 | // 1979-06-12 https://en.wikipedia.org/wiki/MacCready_Gossamer_Albatross |
744 | 1 | (CommonDate::new(1979, 6, 12), CommonDate::new(10, 12, 19)), |
745 | 1 | // 14, 12, 20 |
746 | 1 | // Pioneer 10 exits solar system (1983) |
747 | 1 | // ??? |
748 | 1 | // Ben Franklin flies kite during a lightning storm and discovers electricity (1752) |
749 | 1 | //1752-06-15 https://en.wikipedia.org/wiki/Benjamin_Franklin |
750 | 1 | (CommonDate::new(1752, 6, 15), CommonDate::new(-218, 12, 22)), |
751 | 1 | // Sally Ride becomes first US woman in space (1983) |
752 | 1 | //1983-06-18 https://en.wikipedia.org/wiki/STS-7 |
753 | 1 | (CommonDate::new(1983, 6, 18), CommonDate::new(14, 12, 25)), |
754 | 1 | // Summer solstice, longest day of year, Northern Hemisphere (1990) |
755 | 1 | //1990-06-21 https://aa.usno.navy.mil/calculated/seasons?year=1990&tz=0.00&tz_sign=-1&tz_label=false&dst=false&submit=Get+Data |
756 | 1 | (CommonDate::new(1990, 6, 21), CommonDate::new(21, 12, 28)), |
757 | 1 | // First reported UFO sighting using the term flying saucers (1947) |
758 | 1 | //1947-06-24 https://en.wikipedia.org/wiki/Kenneth_Arnold_UFO_sighting |
759 | 1 | (CommonDate::new(1947, 6, 24), CommonDate::new(-23, 13, 3)), |
760 | 1 | // -13, 13, 4 |
761 | 1 | // CBS broadcasts first commercial color TV program (1957) |
762 | 1 | // ??? |
763 | 1 | // Mysterious explosion devastates a huge forest in Tunguska, Siberia (1908) |
764 | 1 | // 1908-06-30 https://en.wikipedia.org/wiki/Tunguska_event |
765 | 1 | (CommonDate::new(1908, 6, 30), CommonDate::new(-62, 13, 9)), |
766 | 1 | // -83, 13, 15 |
767 | 1 | // Louis Pasteur inoculates a boy with antirabies serum (1887) |
768 | 1 | // ??? |
769 | 1 | // Skylab falls to Earth (1979) |
770 | 1 | // 1979-07-11 https://en.wikipedia.org/wiki/Skylab |
771 | 1 | (CommonDate::new(1979, 7, 11), CommonDate::new(10, 13, 20)), |
772 | 1 | // -8, 13, 22 |
773 | 1 | // First transatlantic conversation using communications satellite (1962) |
774 | 1 | // ??? wiki:https://en.wikipedia.org/wiki/Telstar |
775 | 1 | // First atomic bomb is detonated, Trinity Site, New Mexico (1945) |
776 | 1 | // 1945-07-16 https://en.wikipedia.org/wiki/Trinity_(nuclear_test) |
777 | 1 | (CommonDate::new(1945, 7, 16), CommonDate::new(-25, 13, 25)), |
778 | 1 | ]; |
779 | 50 | for pair49 in d_list { |
780 | 49 | let dg = Gregorian::try_from_common_date(pair.0).unwrap().to_fixed(); |
781 | 49 | let dq = TranquilityMoment::try_from_common_date(pair.1) |
782 | 49 | .unwrap() |
783 | 49 | .to_fixed(); |
784 | 49 | assert_eq!(dq.get_day_i(), dg.get_day_i(), "{:?}"0 , pair); |
785 | | } |
786 | 1 | } |
787 | | |
788 | | #[test] |
789 | 1 | fn orions_arm() { |
790 | 1 | let d_list = [ |
791 | 1 | // Orion's Arm Encyclopaedia Galactica - Atomic Age |
792 | 1 | // https://www.orionsarm.com/eg-topic/460b135b0c6d8 |
793 | 1 | // Orion's Arm Calendar Converter |
794 | 1 | // https://www.orionsarm.com/xcms.php?r=oa-calendar-converter |
795 | 1 | // Wikipedia |
796 | 1 | // https://en.wikipedia.org/wiki/Subrahmanyan_Chandrasekhar |
797 | 1 | // https://en.wikipedia.org/wiki/Albert_Einstein |
798 | 1 | // https://en.wikipedia.org/wiki/Yuri_Gagarin |
799 | 1 | // In cases where articles conflict with the calendar converter, |
800 | 1 | // the calendar converter is used. These cases are marked with * |
801 | 1 | (CommonDate::new(1910, 10, 19), -59), //Chandrasekhar |
802 | 1 | (CommonDate::new(1995, 8, 21), 27), //Chandrasekhar* |
803 | 1 | (CommonDate::new(1879, 3, 14), -91), //Einstein* |
804 | 1 | (CommonDate::new(1955, 4, 18), -15), //Einstein* |
805 | 1 | (CommonDate::new(1934, 3, 9), -36), //Gagarin* |
806 | 1 | (CommonDate::new(1968, 3, 27), -2), //Gagarin* |
807 | 1 | (CommonDate::new(1912, 6, 23), -58), //Turing* |
808 | 1 | (CommonDate::new(1954, 6, 7), -16), //Turing* |
809 | 1 | ]; |
810 | 9 | for pair8 in d_list { |
811 | 8 | let f = Gregorian::try_from_common_date(pair.0).unwrap().to_fixed(); |
812 | 8 | let dq = TranquilityMoment::from_fixed(f); |
813 | 8 | assert_eq!(dq.year(), pair.1); |
814 | | } |
815 | 1 | } |
816 | | |
817 | | proptest! { |
818 | | #[test] |
819 | | fn gregorian_lookup(t in FIXED_MIN..FIXED_MAX) { |
820 | | // https://web.archive.org/web/20180818233025/https://en.wikipedia.org/wiki/Tranquility_calendar |
821 | | let f = RataDie::new(t).to_fixed().to_day(); |
822 | | let g = Gregorian::from_fixed(f); |
823 | | let gc = g.to_common_date(); |
824 | | let q = TranquilityMoment::from_fixed(f); |
825 | | if q.try_month().is_some() { |
826 | | let qm = q.try_month().unwrap(); |
827 | | let entry = match qm { |
828 | | TranquilityMonth::Archimedes => ((7, 21), (8, 17)), |
829 | | TranquilityMonth::Brahe => ((8, 18), (9, 14)), |
830 | | TranquilityMonth::Copernicus => ((9, 15), (10, 12)), |
831 | | TranquilityMonth::Darwin => ((10, 13), (11, 9)), |
832 | | TranquilityMonth::Einstein => ((11, 10), (12, 7)), |
833 | | TranquilityMonth::Faraday => ((12, 8), (1, 4)), |
834 | | TranquilityMonth::Galileo => ((1, 5), (2, 1)), |
835 | | TranquilityMonth::Hippocrates => ((2, 2), (3, 1)), |
836 | | TranquilityMonth::Imhotep => ((3, 2), (3, 29)), |
837 | | TranquilityMonth::Jung => ((3, 30), (4, 26)), |
838 | | TranquilityMonth::Kepler => ((4, 27), (5, 24)), |
839 | | TranquilityMonth::Lavoisier => ((5, 25), (6, 21)), |
840 | | TranquilityMonth::Mendel => ((6, 22), (7, 19)), |
841 | | }; |
842 | | let mut y_min = gc.year; |
843 | | let mut y_max = gc.year; |
844 | | if qm == TranquilityMonth::Faraday { |
845 | | let in_new_year = gc.month == entry.1.0; |
846 | | y_min = if in_new_year { gc.year - 1 } else { gc.year }; |
847 | | y_max = y_min + 1; |
848 | | } |
849 | | let gc_min = CommonDate::new(y_min, entry.0.0, entry.0.1); |
850 | | let gc_max = CommonDate::new(y_max, entry.1.0, entry.1.1); |
851 | | assert!(gc >= gc_min, "gc: {:?}, gc_min: {:?}, q: {:?}", gc, gc_min, q); |
852 | | assert!(gc <= gc_max, "gc: {:?}, gc_max: {:?}, q: {:?}", gc, gc_max, q); |
853 | | } else { |
854 | | let qc = q.complementary().unwrap(); |
855 | | let entry = match qc { |
856 | | TranquilityComplementaryDay::MoonLandingDay => (7, 20), |
857 | | TranquilityComplementaryDay::ArmstrongDay => (7, 20), |
858 | | TranquilityComplementaryDay::AldrinDay => (2, 29) |
859 | | }; |
860 | | assert_eq!(gc.month as i64, entry.0); |
861 | | assert_eq!(gc.day as i64, entry.1); |
862 | | } |
863 | | } |
864 | | |
865 | | #[test] |
866 | | fn gregorian_lookup_small(t in i8::MIN..i8::MAX) { |
867 | | // https://web.archive.org/web/20180818233025/https://en.wikipedia.org/wiki/Tranquility_calendar |
868 | | let e = TranquilityMoment::epoch().get_day_i(); |
869 | | let f = RataDie::cast_new(e + (t as i64)).to_fixed().to_day(); |
870 | | let g = Gregorian::from_fixed(f); |
871 | | let gc = g.to_common_date(); |
872 | | let q = TranquilityMoment::from_fixed(f); |
873 | | if q.try_month().is_some() { |
874 | | let qm = q.try_month().unwrap(); |
875 | | let entry = match qm { |
876 | | TranquilityMonth::Archimedes => ((7, 21), (8, 17)), |
877 | | TranquilityMonth::Brahe => ((8, 18), (9, 14)), |
878 | | TranquilityMonth::Copernicus => ((9, 15), (10, 12)), |
879 | | TranquilityMonth::Darwin => ((10, 13), (11, 9)), |
880 | | TranquilityMonth::Einstein => ((11, 10), (12, 7)), |
881 | | TranquilityMonth::Faraday => ((12, 8), (1, 4)), |
882 | | TranquilityMonth::Galileo => ((1, 5), (2, 1)), |
883 | | TranquilityMonth::Hippocrates => ((2, 2), (3, 1)), |
884 | | TranquilityMonth::Imhotep => ((3, 2), (3, 29)), |
885 | | TranquilityMonth::Jung => ((3, 30), (4, 26)), |
886 | | TranquilityMonth::Kepler => ((4, 27), (5, 24)), |
887 | | TranquilityMonth::Lavoisier => ((5, 25), (6, 21)), |
888 | | TranquilityMonth::Mendel => ((6, 22), (7, 19)), |
889 | | }; |
890 | | let mut y_min = gc.year; |
891 | | let mut y_max = gc.year; |
892 | | if qm == TranquilityMonth::Faraday { |
893 | | let in_new_year = gc.month == entry.1.0; |
894 | | y_min = if in_new_year { gc.year - 1 } else { gc.year }; |
895 | | y_max = y_min + 1; |
896 | | } |
897 | | let gc_min = CommonDate::new(y_min, entry.0.0, entry.0.1); |
898 | | let gc_max = CommonDate::new(y_max, entry.1.0, entry.1.1); |
899 | | assert!(gc >= gc_min, "gc: {:?}, gc_min: {:?}, q: {:?}", gc, gc_min, q); |
900 | | assert!(gc <= gc_max, "gc: {:?}, gc_max: {:?}, q: {:?}", gc, gc_max, q); |
901 | | } else { |
902 | | let qc = q.complementary().unwrap(); |
903 | | let entry = match qc { |
904 | | TranquilityComplementaryDay::MoonLandingDay => (7, 20), |
905 | | TranquilityComplementaryDay::ArmstrongDay => (7, 20), |
906 | | TranquilityComplementaryDay::AldrinDay => (2, 29) |
907 | | }; |
908 | | assert_eq!(gc.month as i64, entry.0); |
909 | | assert_eq!(gc.day as i64, entry.1); |
910 | | } |
911 | | } |
912 | | } |
913 | | } |