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
//! # gnss-time
//!
//! A type-safe GNSS time scale library with zero runtime overhead.
//!
//! Supports conversions between:
//! - GPS
//! - UTC
//! - GLONASS
//! - Galileo
//! - `BeiDou`
//! - TAI
//!
//! ## Feature flags
//!
//! | Feature | Description |
//! |----------|----------------------------------------------------------------------|
//! | `std` | `impl std::error::Error` for error types |
//! | `serde` | `Serialize`/`Deserialize` for `Time<S>`, `Duration`, `DurationParts` |
//! | `defmt` | `impl defmt::Format` for all public types |
//!
//! Leap seconds are handled explicitly via a provider trait, ensuring
//! deterministic behavior and full `no_std` compatibility.
//!
//! ## Design goals
//!
//! - Zero allocations
//! - No global mutable state
//! - Fully deterministic conversions
//! - Embedded-friendly (`no_std`)
//! - Strong type safety across time scales
//!
//! ## Quick start
//!
//! ```rust
//! use gnss_time::prelude::*;
//!
//! let gps = Time::<Gps>::from_week_tow(
//! 2345,
//! DurationParts {
//! seconds: 432_000,
//! nanos: 0,
//! },
//! )
//! .unwrap();
//!
//! assert_eq!(gps.to_string(), "GPS 2345:432000.000");
//!
//! let utc: Time<Utc> = gps.into_scale_with(LeapSeconds::builtin()).unwrap();
//!
//! // ISO 8601 formatting
//! let dt = utc.to_civil();
//! println!("{dt}"); // e.g. "2023-01-01T00:00:18.000000000Z"
//! ```
extern crate std;
////////////////////////////////////////////////////////////////////////////////
// Public modules
////////////////////////////////////////////////////////////////////////////////
// ISO 8601 civil date-time representation derived from `Time<Utc>`.
// Serde implementations for `Time<S>`, `Duration`, and `DurationParts`.
// Enabled by the `serde` feature flag.
////////////////////////////////////////////////////////////////////////////////
// Internal modules
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Public re-exports
////////////////////////////////////////////////////////////////////////////////
pub use CivilDateTime;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
////////////////////////////////////////////////////////////////////////////////
// Prelude
////////////////////////////////////////////////////////////////////////////////
// Common imports for typical usage.