pub struct Time<S: TimeScale> { /* private fields */ }Expand description
A timestamp in time scale S, stored as nanoseconds since the epoch of the
scale.
§Examples
use gnss_time::{Duration, Glonass, Gps, Time};
let t: Time<Gps> = Time::from_nanos(0); // GPS epoch
let later = t + Duration::from_seconds(3600);
assert_eq!((later - t).as_seconds(), 3600);
// Compile-time error — different time scales are incompatible:
// let glo: Time<Glonass> = Time::from_nanos(0);
// let _ = later - glo; // ← ERRORImplementations§
Source§impl<S: TimeScale> Time<S>
impl<S: TimeScale> Time<S>
Sourcepub const EPOCH: Self
pub const EPOCH: Self
The scale’s epoch — 0 nanoseconds.
Corresponds to the calendar date defined by TimeScale::EPOCH_CIVIL
(e.g. 1980-01-06 for GPS, 1996-01-01 for GLONASS).
Sourcepub const MAX: Self
pub const MAX: Self
Maximum representable instant.
u64::MAX nanoseconds ≈ 584.5 years past the scale’s epoch.
| Scale | Epoch | MAX ≈ calendar date |
|---|---|---|
| GLONASS | 1996-01-01 | 2580-07-01 |
| GPS | 1980-01-06 | 2564-07-04 |
| Galileo | 1999-08-22 | 2584-02-15 |
| BeiDou | 2006-01-01 | 2590-07-02 |
| TAI | 1958-01-01 | 2542-07-05 |
| UTC | 1972-01-01 | 2556-07-03 |
Arithmetic near MAX will overflow — use
checked_add,
saturating_add, or try_add.
Sourcepub const NANOS_PER_YEAR: u64
pub const NANOS_PER_YEAR: u64
Nanoseconds per non-leap year (365 days).
Useful for sanity-checking that a value is within a reasonable range:
use gnss_time::{scale::Gps, Time};
// 50 years from GPS epoch
let fifty_years = Time::<Gps>::from_nanos(50 * Time::<Gps>::NANOS_PER_YEAR);
assert!(fifty_years.as_nanos() > 0);Sourcepub const fn from_nanos(nanos: u64) -> Self
pub const fn from_nanos(nanos: u64) -> Self
Construct from raw nanoseconds since this scale’s epoch.
Sourcepub const fn from_seconds(secs: u64) -> Self
pub const fn from_seconds(secs: u64) -> Self
Construct from whole seconds since this scale’s epoch.
§Panics
Panics if secs * 1_000_000_000 overflows u64.
Sourcepub const fn checked_from_seconds(secs: u64) -> Option<Self>
pub const fn checked_from_seconds(secs: u64) -> Option<Self>
Construct from whole seconds, returning None on overflow.
Source§impl<S: TimeScale> Time<S>
impl<S: TimeScale> Time<S>
Sourcepub const fn as_seconds(self) -> u64
pub const fn as_seconds(self) -> u64
Whole seconds since this scale’s epoch (truncated).
Sourcepub fn as_seconds_f64(self) -> f64
pub fn as_seconds_f64(self) -> f64
Seconds as f64. For large timestamps (> ~2^53 ns), precision loss
affects even milliseconds
Source§impl<S: TimeScale> Time<S>
impl<S: TimeScale> Time<S>
Sourcepub fn to_tai(self) -> Result<Time<Tai>, GnssTimeError>
pub fn to_tai(self) -> Result<Time<Tai>, GnssTimeError>
Convert to TAI using the scale’s fixed offset.
Returns GnssTimeError::LeapSecondsRequired for contextual scales
(UTC, GLONASS) and GnssTimeError::Overflow for out-of-range results.
Sourcepub fn from_tai(tai: Time<Tai>) -> Result<Self, GnssTimeError>
pub fn from_tai(tai: Time<Tai>) -> Result<Self, GnssTimeError>
Construct Time<S> from a TAI timestamp using the scale’s fixed offset.
Sourcepub fn try_convert<T: TimeScale>(self) -> Result<Time<T>, GnssTimeError>
pub fn try_convert<T: TimeScale>(self) -> Result<Time<T>, GnssTimeError>
Convert directly between two fixed-offset scales via TAI.
Fails if either source or target scale requires leap seconds.
Source§impl<S: TimeScale> Time<S>
impl<S: TimeScale> Time<S>
Sourcepub fn checked_add(self, d: Duration) -> Option<Self>
pub fn checked_add(self, d: Duration) -> Option<Self>
Add a Duration, returning None on overflow or underflow.
Sourcepub fn checked_sub_duration(self, d: Duration) -> Option<Self>
pub fn checked_sub_duration(self, d: Duration) -> Option<Self>
Subtract a Duration, returning None on overflow or underflow.
Sourcepub fn saturating_add(self, d: Duration) -> Self
pub fn saturating_add(self, d: Duration) -> Self
Add, saturating at EPOCH (below) and MAX (above).
Sourcepub fn saturating_sub_duration(self, d: Duration) -> Self
pub fn saturating_sub_duration(self, d: Duration) -> Self
Subtract duration, saturating at bounds.
Sourcepub fn try_add(self, d: Duration) -> Result<Self, GnssTimeError>
pub fn try_add(self, d: Duration) -> Result<Self, GnssTimeError>
Fallible add — GnssTimeError::Overflow on failure.
Sourcepub fn try_sub_duration(self, d: Duration) -> Result<Self, GnssTimeError>
pub fn try_sub_duration(self, d: Duration) -> Result<Self, GnssTimeError>
Fallible subtract — GnssTimeError::Overflow on failure.
Source§impl<S: TimeScale> Time<S>
impl<S: TimeScale> Time<S>
Sourcepub const fn checked_elapsed(self, earlier: Time<S>) -> Option<Duration>
pub const fn checked_elapsed(self, earlier: Time<S>) -> Option<Duration>
Signed interval self − earlier. Returns None if it overflows i64.
Source§impl Time<Glonass>
impl Time<Glonass>
Sourcepub fn from_day_tod(day: u32, tod: DurationParts) -> Result<Self, GnssTimeError>
pub fn from_day_tod(day: u32, tod: DurationParts) -> Result<Self, GnssTimeError>
Construct from GLONASS day number and time-of-day.
tod.seconds must be in [0, 86_400).
tod.nanos must be in [0, 1_000_000_000).
§Errors
GnssTimeError::InvalidInput if tod_s ∉ [0, 86 400).
Sourcepub const fn tod_seconds(self) -> u32
pub const fn tod_seconds(self) -> u32
Time of day in whole seconds.
Sourcepub const fn sub_second_nanos(self) -> u32
pub const fn sub_second_nanos(self) -> u32
Sub-second nanosecond remainder within the current second.
Sourcepub const fn day_of_week(self) -> u8
pub const fn day_of_week(self) -> u8
Day of week: 1 = Monday … 7 = Sunday (NavIC / ISO 8601 convention).
GLONASS epoch (1996-01-01) was a Monday, so day 0 → 1 (Monday).
The formula is simply (day % 7) + 1.
§GLONASS ICD note
The GLONASS Interface Control Document defines the “day number within
the four-year interval” (N_T) starting from 1, but for simplicity
this crate uses 0-based day counts from the epoch and exposes the
ISO / NavIC weekday (1=Mon … 7=Sun) through this method.
§Examples
use gnss_time::{scale::Glonass, DurationParts, Time};
// Day 0 = 1996-01-01 = Monday
let t = Time::<Glonass>::from_day_tod(
0,
DurationParts {
seconds: 0,
nanos: 0,
},
)
.unwrap();
assert_eq!(t.day_of_week(), 1); // Monday
// Day 6 = 1996-01-07 = Sunday
let t2 = Time::<Glonass>::from_day_tod(
6,
DurationParts {
seconds: 0,
nanos: 0,
},
)
.unwrap();
assert_eq!(t2.day_of_week(), 7); // Sunday
// Day 7 = 1996-01-08 = Monday again
let t3 = Time::<Glonass>::from_day_tod(
7,
DurationParts {
seconds: 0,
nanos: 0,
},
)
.unwrap();
assert_eq!(t3.day_of_week(), 1);Sourcepub const fn is_weekend(self) -> bool
pub const fn is_weekend(self) -> bool
Returns true if the current day-of-week is Saturday (6) or Sunday (7).
Source§impl Time<Gps>
impl Time<Gps>
Sourcepub fn from_week_tow(
week: u16,
tow: DurationParts,
) -> Result<Self, GnssTimeError>
pub fn from_week_tow( week: u16, tow: DurationParts, ) -> Result<Self, GnssTimeError>
Construct from GPS week number and time-of-week.
tow.seconds must be in [0, 604_800).
tow.nanos must be in [0, 1_000_000_000).
Sourcepub fn to_utc(self) -> Result<Time<Utc>, GnssTimeError>
pub fn to_utc(self) -> Result<Time<Utc>, GnssTimeError>
Conversion of GPS time to UTC using the built-in leap seconds table.
§Accuracy
For most timestamps, the conversion is accurate to the nanosecond.
During a leap second insertion window (e.g. 2016-12-31 23:59:60 UTC),
the result may differ by up to 1 second. If this is critical, use
to_utc_with with a custom provider that properly
handles the ambiguity.
Sourcepub fn to_utc_with<P: LeapSecondsProvider>(
self,
ls: &P,
) -> Result<Time<Utc>, GnssTimeError>
pub fn to_utc_with<P: LeapSecondsProvider>( self, ls: &P, ) -> Result<Time<Utc>, GnssTimeError>
Conversion of GPS time to UTC using a custom leap seconds provider.
The same accuracy notes apply as for to_utc:
the conversion is precise for most timestamps, but during a leap second
insertion window it may differ by up to 1 second.
Sourcepub const fn tow_seconds(self) -> u32
pub const fn tow_seconds(self) -> u32
Time of week in whole seconds.
Sourcepub const fn sub_second_nanos(self) -> u32
pub const fn sub_second_nanos(self) -> u32
Sub-second nanosecond remainder within the current second.
Source§impl Time<Utc>
impl Time<Utc>
Sourcepub fn to_gps_with<P: LeapSecondsProvider>(
self,
ls: &P,
) -> Result<Time<Gps>, GnssTimeError>
pub fn to_gps_with<P: LeapSecondsProvider>( self, ls: &P, ) -> Result<Time<Gps>, GnssTimeError>
Conversion of UTC time to GPS using a custom leap seconds provider.
The same accuracy notes apply as for to_gps:
ambiguity may occur during leap second insertion events.
Trait Implementations§
Source§impl<S: TimeScale> AddAssign<Duration> for Time<S>
impl<S: TimeScale> AddAssign<Duration> for Time<S>
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moreSource§impl IntoScale<Beidou> for Time<Galileo>
impl IntoScale<Beidou> for Time<Galileo>
Source§fn into_scale(self) -> Result<Time<Beidou>, GnssTimeError>
fn into_scale(self) -> Result<Time<Beidou>, GnssTimeError>
Galileo -> BeiDou via TAI.
Source§impl IntoScale<Beidou> for Time<Gps>
impl IntoScale<Beidou> for Time<Gps>
Source§fn into_scale(self) -> Result<Time<Beidou>, GnssTimeError>
fn into_scale(self) -> Result<Time<Beidou>, GnssTimeError>
GPS -> BeiDou: BDT = GPS - 14s.
use gnss_time::{Beidou, Gps, IntoScale, Time};
let gps = Time::<Gps>::from_seconds(100);
let bdt: Time<Beidou> = gps.into_scale().unwrap();
assert_eq!(bdt.as_seconds(), 86); // 100 - 14 = 86Source§impl IntoScale<Galileo> for Time<Beidou>
impl IntoScale<Galileo> for Time<Beidou>
Source§fn into_scale(self) -> Result<Time<Galileo>, GnssTimeError>
fn into_scale(self) -> Result<Time<Galileo>, GnssTimeError>
BeiDou -> Galileo via TAI.
Source§impl IntoScale<Galileo> for Time<Gps>
impl IntoScale<Galileo> for Time<Gps>
Source§fn into_scale(self) -> Result<Time<Galileo>, GnssTimeError>
fn into_scale(self) -> Result<Time<Galileo>, GnssTimeError>
GPS -> Galileo: identical at nanosecond level (both use TAI − 19s).
GPS and Galileo timestamps with identical nanoseconds represent the same physical instant.
use gnss_time::{Galileo, Gps, IntoScale, Time};
let gps = Time::<Gps>::from_seconds(12_345);
let gal: Time<Galileo> = gps.into_scale().unwrap();
assert_eq!(gps.as_nanos(), gal.as_nanos());Source§impl IntoScale<Glonass> for Time<Utc>
impl IntoScale<Glonass> for Time<Utc>
Source§fn into_scale(self) -> Result<Time<Glonass>, GnssTimeError>
fn into_scale(self) -> Result<Time<Glonass>, GnssTimeError>
UTC -> GLONASS: постоянный сдвиг эпохи.
§Errors
GnssTimeError::Overflow если UTC раньше эпохи GLONASS
(1995-12-31 21:00:00 UTC).
Source§impl IntoScale<Gps> for Time<Beidou>
impl IntoScale<Gps> for Time<Beidou>
Source§fn into_scale(self) -> Result<Time<Gps>, GnssTimeError>
fn into_scale(self) -> Result<Time<Gps>, GnssTimeError>
BeiDou -> GPS: GPS = BDT + 14s.
use gnss_time::{Beidou, Gps, IntoScale, Time};
let bdt = Time::<Beidou>::from_seconds(86);
let gps: Time<Gps> = bdt.into_scale().unwrap();
assert_eq!(gps.as_seconds(), 100); // 86 - 19 + 33 = 100Source§impl IntoScale<Gps> for Time<Galileo>
impl IntoScale<Gps> for Time<Galileo>
Source§fn into_scale(self) -> Result<Time<Gps>, GnssTimeError>
fn into_scale(self) -> Result<Time<Gps>, GnssTimeError>
Source§impl IntoScale<Gps> for Time<Tai>
impl IntoScale<Gps> for Time<Tai>
Source§fn into_scale(self) -> Result<Time<Gps>, GnssTimeError>
fn into_scale(self) -> Result<Time<Gps>, GnssTimeError>
TAI -> GPS: subtract 19 seconds.
use gnss_time::{Gps, IntoScale, Tai, Time};
let tai = Time::<Tai>::from_seconds(119);
let gps: Time<Gps> = tai.into_scale().unwrap();
assert_eq!(gps.as_seconds(), 100);Source§impl IntoScale<Tai> for Time<Gps>
impl IntoScale<Tai> for Time<Gps>
Source§fn into_scale(self) -> Result<Time<Tai>, GnssTimeError>
fn into_scale(self) -> Result<Time<Tai>, GnssTimeError>
GPS -> TAI: add 19 seconds (constant, no leap seconds).
use gnss_time::{Gps, IntoScale, Tai, Time};
let gps = Time::<Gps>::from_seconds(100);
let tai: Time<Tai> = gps.into_scale().unwrap();
assert_eq!(tai.as_seconds(), 119);Source§impl IntoScale<Utc> for Time<Glonass>
impl IntoScale<Utc> for Time<Glonass>
Source§fn into_scale(self) -> Result<Time<Utc>, GnssTimeError>
fn into_scale(self) -> Result<Time<Utc>, GnssTimeError>
GLONASS -> UTC: fixed epoch shift.
GLONASS uses UTC(SU), a time scale offset from UTC by +3 hours and including leap seconds.
use gnss_time::{DurationParts, Glonass, IntoScale, Time, Utc};
let glo = Time::<Glonass>::from_day_tod(
0,
DurationParts {
seconds: 0,
nanos: 0,
},
)
.unwrap(); // GLONASS epoch
let utc: Time<Utc> = glo.into_scale().unwrap();
// UTC at the GLONASS epoch:
// 1995-12-31 21:00:00 UTC = 757_371_600 s from 1972
assert_eq!(utc.as_nanos(), 757_371_600_000_000_000);Source§impl IntoScaleWith<Beidou> for Time<Glonass>
impl IntoScaleWith<Beidou> for Time<Glonass>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Beidou>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Beidou>, GnssTimeError>
GLONASS -> BeiDou via UTC.
Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Beidou>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Beidou>>, GnssTimeError>
Source§impl IntoScaleWith<Beidou> for Time<Utc>
impl IntoScaleWith<Beidou> for Time<Utc>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Beidou>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Beidou>, GnssTimeError>
UTC → BeiDou via GPS.
Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Beidou>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Beidou>>, GnssTimeError>
Source§impl IntoScaleWith<Galileo> for Time<Glonass>
impl IntoScaleWith<Galileo> for Time<Glonass>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Galileo>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Galileo>, GnssTimeError>
GLONASS -> Galileo via UTC.
Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Galileo>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Galileo>>, GnssTimeError>
Source§impl IntoScaleWith<Galileo> for Time<Utc>
impl IntoScaleWith<Galileo> for Time<Utc>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Galileo>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Galileo>, GnssTimeError>
UTC -> Galileo via GPS.
Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Galileo>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Galileo>>, GnssTimeError>
Source§impl IntoScaleWith<Glonass> for Time<Beidou>
impl IntoScaleWith<Glonass> for Time<Beidou>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Glonass>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Glonass>, GnssTimeError>
Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Glonass>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Glonass>>, GnssTimeError>
Source§impl IntoScaleWith<Glonass> for Time<Galileo>
impl IntoScaleWith<Glonass> for Time<Galileo>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Glonass>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Glonass>, GnssTimeError>
Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Glonass>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Glonass>>, GnssTimeError>
Source§impl IntoScaleWith<Glonass> for Time<Gps>
impl IntoScaleWith<Glonass> for Time<Gps>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Glonass>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Glonass>, GnssTimeError>
Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Glonass>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Glonass>>, GnssTimeError>
Source§impl IntoScaleWith<Gps> for Time<Glonass>
impl IntoScaleWith<Gps> for Time<Glonass>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Gps>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Gps>, GnssTimeError>
GLONASS -> GPS via UTC.
Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Gps>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Gps>>, GnssTimeError>
Source§impl IntoScaleWith<Gps> for Time<Utc>
impl IntoScaleWith<Gps> for Time<Utc>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Gps>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Gps>, GnssTimeError>
UTC -> GPS with leap-second context.
use gnss_time::{DurationParts, Gps, IntoScale, IntoScaleWith, LeapSeconds, Time, Utc};
let ls = LeapSeconds::builtin();
let gps_orig = Time::<Gps>::from_week_tow(
2086,
DurationParts {
seconds: 0,
nanos: 0,
},
)
.unwrap();
let utc: Time<Utc> = gps_orig.into_scale_with(ls).unwrap();
let gps_back: Time<Gps> = utc.into_scale_with(ls).unwrap();
assert_eq!(gps_orig, gps_back);Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Gps>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Gps>>, GnssTimeError>
Source§impl IntoScaleWith<Utc> for Time<Beidou>
impl IntoScaleWith<Utc> for Time<Beidou>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Utc>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Utc>, GnssTimeError>
BeiDou -> UTC via GPS.
Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Utc>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Utc>>, GnssTimeError>
Source§impl IntoScaleWith<Utc> for Time<Galileo>
impl IntoScaleWith<Utc> for Time<Galileo>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Utc>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Utc>, GnssTimeError>
Galileo -> UTC via GPS (both share the same TAI offset of 19s).
Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Utc>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Utc>>, GnssTimeError>
Source§impl IntoScaleWith<Utc> for Time<Gps>
impl IntoScaleWith<Utc> for Time<Gps>
Source§fn into_scale_with<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<Time<Utc>, GnssTimeError>
fn into_scale_with<P: LeapSecondsProvider>( self, ls: P, ) -> Result<Time<Utc>, GnssTimeError>
GPS -> UTC with leap-second context.
Round-trip consistency: GPS -> UTC -> GPS is exact (< 1 ns) for all
moments except the one-second leap-second insertion window.
use gnss_time::{Gps, IntoScaleWith, LeapSeconds, Time, Utc};
let ls = LeapSeconds::builtin();
let gps = Time::<Gps>::from_seconds(1_167_264_018); // 2017-01-01 GPS
let utc: Time<Utc> = gps.into_scale_with(ls).unwrap();
let delta = gps.as_seconds() as i64 - utc.as_seconds() as i64 + 252_892_800_i64;
// GPS leads UTC by 18 s → UTC is 18 s earlier
assert_eq!(delta, 18);Source§fn into_scale_with_checked<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<ConvertResult<Time<Utc>>, GnssTimeError>
fn into_scale_with_checked<P: LeapSecondsProvider>( self, ls: P, ) -> Result<ConvertResult<Time<Utc>>, GnssTimeError>
Source§impl<S: TimeScale> Ord for Time<S>
impl<S: TimeScale> Ord for Time<S>
Source§impl<S: TimeScale> PartialOrd for Time<S>
impl<S: TimeScale> PartialOrd for Time<S>
Source§impl<S: TimeScale> SubAssign<Duration> for Time<S>
impl<S: TimeScale> SubAssign<Duration> for Time<S>
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-= operation. Read more