1#![cfg_attr(not(feature = "std"), no_std)]
2
3#[cfg(feature = "alloc")]
4extern crate alloc;
5#[cfg(feature = "std")]
6extern crate std;
7
8#[cfg(all(feature = "panic-handler", not(feature = "std"), not(test)))]
12use core::panic::PanicInfo;
13
14#[cfg(all(feature = "panic-handler", not(feature = "std"), not(test)))]
15#[panic_handler]
16fn panic(_info: &PanicInfo) -> ! {
17 loop {
19 core::hint::spin_loop();
20 }
21}
22
23pub type Real = f64;
25
26#[macro_export]
27macro_rules! f {
28 ($x:expr) => {
29 $x as $crate::Real
30 };
31}
32
33#[inline(always)]
34pub const fn to_sec_f(attos: u128) -> Real {
35 f!(attos) / ATTOS_PER_SECF
36}
37
38#[inline(always)]
40pub fn to_sec(attos: i128) -> i128 {
41 attos / ATTOS_PER_SEC_I128
42}
43
44#[inline(always)]
46pub fn to_ms(attos: i128) -> i128 {
47 attos / ATTOS_PER_MS_I128
48}
49
50#[inline(always)]
52pub fn to_us(attos: i128) -> i128 {
53 attos / ATTOS_PER_US_I128
54}
55
56#[inline(always)]
58pub fn to_ns(attos: i128) -> i128 {
59 attos / ATTOS_PER_NS_I128
60}
61
62#[inline(always)]
64pub fn to_ps(attos: i128) -> i128 {
65 attos / ATTOS_PER_PS_I128
66}
67
68#[inline(always)]
70pub fn to_fs(attos: i128) -> i128 {
71 attos / ATTOS_PER_FS_I128
72}
73
74#[cfg(feature = "parse")]
78mod alloc_parse;
79
80#[cfg(feature = "sidereal")]
81mod sidereal;
82
83mod an_err;
87mod ascii_str;
88mod clock_model;
89mod drift;
90mod dt;
91mod gregorian_time;
92mod light_time;
93mod parser;
94mod position;
95mod scale;
96mod time_parts;
97mod time_range;
98
99pub mod constants;
103pub mod error;
104pub mod historical_sofa;
105pub mod leap_seconds;
106pub mod tzdb;
107pub mod utils;
108
109#[cfg(feature = "bop")]
113pub mod bop;
114
115#[cfg(feature = "parse")]
119pub(crate) use alloc_parse::{
120 alloc_constants::*, date::*, date_classification::*, duration::*, lang_data::*, lang_map::*,
121 languages::en::*, parse_date::*, types::*,
122};
123
124pub(crate) use constants::*;
128pub(crate) use utils::*;
129
130#[cfg(feature = "parse")]
134pub use alloc_parse::types::{DateOrder, DateParseMode, Lang, ParseCfg};
135
136#[cfg(feature = "wire")]
137pub use an_err::{WireErr, WireLocation};
138
139#[cfg(feature = "sidereal")]
140pub use sidereal::Sidereal;
141
142pub use an_err::AnErr;
146pub use ascii_str::{AsciiStr, AsciiStrError};
147pub use clock_model::ClockModel;
148pub use drift::{Drift, Spacetime};
149pub use dt::Dt;
150pub use dt::numbers_traits::{AttosTraits, TimeTraits};
151pub use error::{DtErr, DtErrKind};
152pub use gregorian_time::{GregorianTime, YmdHms};
153pub use light_time::ObserverState;
154pub use position::{Position, Velocity};
155pub use scale::Scale;
156pub use time_parts::{Meridiem, Offset, TimeParts, Weekday};
157pub use time_range::{Every, TimeRange};