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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//! Astronomical time scales and conversions with nanosecond resolution.
//!
//! [`Time`] stores an instant with a type-level [`Scale`]. The scale marker
//! prevents accidental mixing of values while the conversion implementations
//! make changes of scale explicit:
//!
//! ```
//! use anytime::{Time, scales::{TAI, UTC}};
//!
//! let utc = Time::<UTC>::from_jd(2_451_545.0);
//! let tai: Time<TAI> = utc.into();
//! # assert_eq!(tai.utc().jd(), 2_451_545.0);
//! ```
//!
//! Values can also be compared and differenced directly, even when they use
//! different scales. Subtraction returns a `chrono::TimeDelta`, while
//! comparisons use standard ordering operators:
//!
//! ```
//! use anytime::{Time, scales::{TAI, UTC}};
//! use chrono::TimeDelta;
//!
//! let earlier = Time::<UTC>::from_jd(2_451_545.0);
//! let later: Time<TAI> = Time::<UTC>::from_jd(2_451_546.0).into();
//! let is_ordered = earlier < later;
//! let difference = later - earlier;
//! # assert!(is_ordered);
//! # assert_eq!(difference, TimeDelta::seconds(86_400));
//! ```
//!
//! A value can be formatted as a Gregorian date string, including sub-second
//! precision, through [`Time::gregorian`]:
//!
//! ```
//! use anytime::{Time, scales::UTC};
//! use chrono::NaiveDate;
//!
//! let date = NaiveDate::from_ymd_opt(2000, 1, 1)
//! .unwrap()
//! .and_hms_nano_opt(12, 0, 0, 123_456_789)
//! .unwrap();
//! let date_string = Time::<UTC>::from_gregorian(date)
//! .gregorian()
//! .to_string();
//! # assert_eq!(date_string, "2000-01-01 12:00:00.123456789");
//! ```
//!
//! When the scale is selected at runtime, use [`AnyTime`]'s constructors with
//! [`TimeScale`]:
//!
//! ```
//! use anytime::{AnyTime, TimeScale};
//!
//! let utc = AnyTime::from_isot_str("2000-01-01T12:00:00", TimeScale::UTC).unwrap();
//! # assert_eq!(utc, AnyTime::from_jd(2_451_545.0, TimeScale::UTC));
//! ```
//!
//! When the scale for a whole collection is selected at runtime, use
//! [`AnyTimeSeries`]. It stores the scale once while retaining a homogeneous
//! typed series internally:
//!
//! ```
//! use anytime::{AnyTimeSeries, Time, TimeSeries, scales::{TAI, UTC}};
//!
//! let tai = TimeSeries::new(vec![Time::<TAI>::from_jd(2_451_545.0)]);
//! let series: AnyTimeSeries = tai.into();
//! let utc: TimeSeries<UTC> = series.into();
//!
//! assert_eq!(utc.len(), 1);
//! ```
//!
//! Convert a runtime-selected value to another runtime-selected scale with
//! [`AnyTime::convert`]:
//!
//! ```
//! use anytime::{AnyTime, TimeScale};
//!
//! let utc = AnyTime::from_jd(2_451_545.0, TimeScale::UTC);
//! let tai = utc.convert(TimeScale::TAI);
//! # assert_eq!(tai.scale(), TimeScale::TAI);
//! ```
//!
//! Typed values also support the same parsing constructors. [`std::str::FromStr`]
//! assumes an ISO 8601 `T`-separated date and time without an offset, interpreted
//! in the type's scale:
//!
//! ```
//! use anytime::{Time, scales::UTC};
//!
//! let utc: Time<UTC> = "2000-01-01T12:00:00".parse().unwrap();
//! # assert_eq!(utc, Time::<UTC>::from_jd(2_451_545.0));
//! ```
//!
//! The crate supports UTC, TAI, TT, TCG, TCB, TDB, and UT1. Its GNSS scales are
//! BDT, GLONASST, GPST, GST, and QZZST. UTC conversions use leap-second data built
//! into the crate. UT1 conversions additionally use Earth-orientation data loaded
//! with [`load_finals2000a`].
//!
//! # Feature overview
//!
//! - Use [`Time::from_jd`], [`Time::from_mjd`], [`Time::from_split_jd`], or
//! [`Time::from_gregorian`] to construct a typed value, or [`AnyTime`]'s
//! runtime-scale constructors when the scale is chosen dynamically.
//! - Use [`Time::jd`], [`Time::mjd`], [`Time::split_jd`], or
//! [`Time::gregorian`] to inspect a value.
//! - Use the `From`/`Into` implementations or [`Time::utc`], [`Time::tai`], and
//! the other scale methods to convert values.
//! - Use [`TimeSeries`] for stored collections or [`TimeSeries::range_iter`]
//! for lazy ranges. Use [`AnyTimeSeries`] when the common series scale is
//! selected at runtime.
//! - Use [`AnyTime`] when a collection may contain values from multiple scales.
//! - Enable the `serde` feature to serialize and deserialize [`Time`],
//! [`AnyTime`], [`TimeSeries`], [`AnyTimeSeries`], and [`TimeScale`] values.
//!
// Astronomical time-scale names intentionally retain their standard acronyms.
pub use ;
pub use AnyTime;
pub use ;
pub use ;
pub use ;
pub use ;