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 = "sidereal")]
108pub mod sidereal;
109
110mod an_err;
114mod ascii_str;
115mod clock_model;
116mod drift;
117mod dt;
118mod gregorian_time;
119mod light_time;
120mod parser;
121mod position;
122mod scale;
123mod time_parts;
124mod time_range;
125
126pub mod constants;
130pub mod error;
131pub mod historical_sofa;
132pub mod leap_seconds;
133pub mod math;
134pub mod tzdb;
135
136#[cfg(feature = "bop")]
140pub mod bop;
141
142#[cfg(feature = "parse")]
146pub(crate) use alloc_parse::{
147 alloc_constants::*, date::*, date_classification::*, duration::*, lang_data::*, lang_map::*,
148 languages::en::*, parse_date::*, types::*,
149};
150
151pub(crate) use constants::*;
155
156#[cfg(feature = "parse")]
160pub use alloc_parse::types::{DateOrder, DateParseMode, Lang, ParseCfg};
161
162#[cfg(feature = "wire")]
163pub use an_err::{WireErr, WireLocation};
164
165#[cfg(feature = "sidereal")]
166pub use sidereal::Sidereal;
167
168#[cfg(feature = "mars")]
169pub use dt::mars;
170
171pub use an_err::AnErr;
175pub use ascii_str::{AsciiStr, AsciiStrError};
176pub use clock_model::ClockModel;
177pub use drift::{Drift, Spacetime};
178pub use dt::numbers_traits::{AttosTraits, TimeTraits};
179pub use dt::{Dt, lunar};
180pub use error::{DtErr, DtErrKind};
181pub use gregorian_time::{GregorianTime, YmdHms};
182pub use light_time::ObserverState;
183pub use math::{
184 atan::atan,
185 atan2::atan2,
186 cos::cos,
187 floor::floor_f,
188 log::log,
189 sin::sin,
190 sqrt::{hypot, sqrt},
191 tan::tan,
192};
193pub use position::{Position, Velocity};
194pub use scale::Scale;
195pub use time_parts::{Meridiem, Offset, TimeParts, Weekday};
196pub use time_range::{Every, TimeRange};