1#![cfg_attr(test, allow(clippy::all))]
2#![cfg_attr(not(feature = "std"), no_std)]
3
4#[cfg(feature = "alloc")]
5extern crate alloc;
6#[cfg(feature = "std")]
7extern crate std;
8
9#[cfg(all(feature = "panic-handler", not(feature = "std"), not(test)))]
13use core::panic::PanicInfo;
14
15#[cfg(all(feature = "panic-handler", not(feature = "std"), not(test)))]
16#[panic_handler]
17fn panic(_info: &PanicInfo) -> ! {
18 loop {
20 core::hint::spin_loop();
21 }
22}
23
24pub type Real = f64;
26
27#[macro_export]
31macro_rules! f {
32 ($x:expr) => {
33 $x as $crate::Real
34 };
35}
36
37macro_rules! safe_div_euc {
40 ($lhs:expr, $rhs:expr, $default:expr) => {{
41 match ($lhs).checked_div_euclid($rhs) {
42 Some(q) => q,
43 None => $default,
44 }
45 }};
46}
47
48macro_rules! safe_rem_euc {
51 ($lhs:expr, $rhs:expr, $default:expr) => {{
52 match ($lhs).checked_rem_euclid($rhs) {
53 Some(r) => r,
54 None => $default,
55 }
56 }};
57}
58
59#[inline(always)]
61pub const fn to_sec_f(attos: u128) -> Real {
62 f!(attos) / ATTOS_PER_SECF
63}
64
65#[inline(always)]
67pub fn to_sec(attos: i128) -> i128 {
68 attos / ATTOS_PER_SEC_I128
69}
70
71#[inline(always)]
73pub fn to_ms(attos: i128) -> i128 {
74 attos / ATTOS_PER_MS_I128
75}
76
77#[inline(always)]
79pub fn to_us(attos: i128) -> i128 {
80 attos / ATTOS_PER_US_I128
81}
82
83#[inline(always)]
85pub fn to_ns(attos: i128) -> i128 {
86 attos / ATTOS_PER_NS_I128
87}
88
89#[inline(always)]
91pub fn to_ps(attos: i128) -> i128 {
92 attos / ATTOS_PER_PS_I128
93}
94
95#[inline(always)]
97pub fn to_fs(attos: i128) -> i128 {
98 attos / ATTOS_PER_FS_I128
99}
100
101#[cfg(feature = "parse")]
105mod alloc_parse;
106
107#[cfg(feature = "wire")]
108mod wire;
109
110mod an_err;
114mod ascii_str;
115mod drift;
116mod dt;
117mod gregorian_time;
118mod light_time;
119mod parser;
120mod position;
121mod scale;
122mod time_parts;
123mod time_range;
124
125pub mod constants;
129pub mod error;
130pub mod historical_sofa;
131pub mod leap_seconds;
132pub mod math;
133pub mod tzdb;
134
135#[cfg(feature = "eop")]
139pub mod eop;
140
141#[cfg(feature = "sidereal")]
142pub mod sidereal;
143
144#[cfg(feature = "parse")]
148pub(crate) use alloc_parse::{
149 alloc_constants::*, date::*, date_classification::*, duration::*, lang_data::*, lang_map::*,
150 languages::en::*, parse_date::*, types::*,
151};
152
153pub(crate) use constants::*;
157
158#[cfg(feature = "parse")]
162pub use alloc_parse::types::{Lang, Mode, Order, ParseCfg};
163
164#[cfg(feature = "wire")]
165pub use an_err::{WireErr, WireLocation};
166
167#[cfg(feature = "sidereal")]
168pub use sidereal::Sidereal;
169
170#[cfg(feature = "mars")]
171pub use dt::mars;
172
173pub use an_err::AnErr;
177pub use ascii_str::{AsciiStr, AsciiStrError};
178pub use drift::{Drift, Spacetime};
179pub use dt::numbers_traits::{AttosTraits, TimeTraits};
180pub use dt::{Dt, lunar};
181pub use error::{DtErr, DtErrKind};
182pub use gregorian_time::{GregorianTime, YmdHms};
183pub use light_time::ObserverState;
184pub use math::{
185 atan::atan,
186 atan2::atan2,
187 cos::cos,
188 div::rem_euclid_f,
189 floor::floor_f,
190 log::log,
191 sin::sin,
192 sqrt::{hypot, sqrt},
193 tan::tan,
194};
195pub use position::{Position, Velocity};
196pub use scale::Scale;
197pub use time_parts::{Meridiem, Offset, TimeParts, Weekday};
198pub use time_range::{Every, TimeRange};