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 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 does not fit into 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.
Sourcepub const fn as_seconds(self) -> u64
pub const fn as_seconds(self) -> u64
Whole seconds since this scale’s epoch (truncated).
Sourcepub const fn as_parts(self) -> (u64, u32)
pub const fn as_parts(self) -> (u64, u32)
Seconds as f64. For large timestamps (> ~2^53 ns), precision loss
affects even milliseconds
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.
§Errors
Returns:
GnssTimeError::LeapSecondsRequiredif the time scale is contextual (e.g. UTC or GLONASS) and does not have a fixed TAI offset.GnssTimeError::Overflowif applying the offset causes the resulting timestamp to fall outside the validu64nanosecond range.
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.
§Errors
Returns:
GnssTimeError::LeapSecondsRequiredif the target time scale is contextual and requires leap-second handling (e.g. UTC, GLONASS).GnssTimeError::Overflowif applying the offset causes the result to underflow below 0 or overflow pastu64::MAX.
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.
§Errors
Returns GnssTimeError::Overflow if the intermediate TAI conversion
would exceed the representable u64 range.
Returns GnssTimeError::LeapSecondsRequired if either the source or
the target scale is contextual and needs leap seconds.
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.
§Errors
Returns GnssTimeError::Overflow if the resulting timestamp would
exceed the representable range of u64 nanoseconds since the scale’s
epoch.
Returns GnssTimeError::InvalidInput if the input duration is not
valid for this operation (if applicable).
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.
§Errors
Returns GnssTimeError::Overflow if the resulting timestamp would
be less than zero or exceed the representable range of u64 nanoseconds
since the scale’s epoch.
This can happen when subtracting a duration larger than the current timestamp.
Sourcepub fn checked_elapsed(self, earlier: Time<S>) -> Option<Duration>
pub 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>
Constructs a GPS time 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).
§Errors
Returns GnssTimeError::InvalidInput if:
tow.seconds >= 604_800tow.nanos >= 1_000_000_000
Returns GnssTimeError::Overflow if the resulting nanosecond
calculation exceeds u64::MAX.
Sourcepub fn from_unix_seconds<P: LeapSecondsProvider>(
unix_seconds: i64,
ls: P,
) -> Result<Self, GnssTimeError>
pub fn from_unix_seconds<P: LeapSecondsProvider>( unix_seconds: i64, ls: P, ) -> Result<Self, GnssTimeError>
Создаёт GPS время из Unix timestamp (секунды с 1970-01-01 UTC).
§Errors
Returns GnssTimeError::Overflow if:
- the intermediate UTC conversion overflows internal
u64nanoseconds - the resulting GPS time cannot be represented in the internal range
Returns any error propagated from UTC conversion, such as:
GnssTimeError::Overflowwhen the Unix timestamp is before the UTC epoch
Sourcepub fn as_unix_seconds<P: LeapSecondsProvider>(
self,
ls: P,
) -> Result<i64, GnssTimeError>
pub fn as_unix_seconds<P: LeapSecondsProvider>( self, ls: P, ) -> Result<i64, GnssTimeError>
Returns this GPS timestamp as a Unix timestamp (whole seconds since 1970-01-01 UTC).
The conversion is GPS -> UTC -> Unix and therefore requires an
explicit leap-second provider.
§Errors
GnssTimeError::Overflow if the UTC conversion fails.
use gnss_time::{Gps, LeapSeconds, Time};
let ls = LeapSeconds::builtin();
// GPS epoch = 1980-01-06 → Unix 315_964_800
assert_eq!(Time::<Gps>::EPOCH.as_unix_seconds(ls).unwrap(), 315_964_800);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.
§Errors
Returns GnssTimeError::Overflow if arithmetic overflow occurs during
conversion.
Returns GnssTimeError::LeapSecondsRequired if leap second data is
insufficient or conversion cannot be resolved.
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.
§Errors
Returns GnssTimeError::Overflow if the conversion fails due to
arithmetic overflow during GPS → UTC transformation.
Returns any error propagated from the underlying conversion logic
(see gps_to_utc), such as invalid time ranges.
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 from_unix_seconds(unix_seconds: i64) -> Result<Self, GnssTimeError>
pub fn from_unix_seconds(unix_seconds: i64) -> Result<Self, GnssTimeError>
Construct from a Unix timestamp (whole seconds since 1970-01-01 UTC).
Time<Utc> counts nanoseconds from 1972-01-01 (UTC epoch), while
Unix time starts from 1970-01-01. The gap is
UTC_EPOCH_UNIX_OFFSET_S = 63 072 000 s (730 days).
§Errors
Returns GnssTimeError::Overflow if unix_seconds < 63_072_000
(i.e. the date is before 1972-01-01 00:00:00 UTC, the UTC epoch).
§Example
use gnss_time::{Time, Utc, UTC_EPOCH_UNIX_OFFSET_S};
// Unix epoch (1970-01-01) is before the UTC epoch → error
assert!(Time::<Utc>::from_unix_seconds(0).is_err());
// 63_072_000 s from Unix epoch = 1972-01-01 = UTC epoch
let utc = Time::<Utc>::from_unix_seconds(UTC_EPOCH_UNIX_OFFSET_S).unwrap();
assert_eq!(utc, Time::<Utc>::EPOCH);
// Round-trip
let unix_s: i64 = 1_700_000_000;
let utc2 = Time::<Utc>::from_unix_seconds(unix_s).unwrap();
assert_eq!(utc2.as_unix_seconds(), unix_s);Sourcepub fn from_unix_nanos(unix_nanos: i64) -> Result<Self, GnssTimeError>
pub fn from_unix_nanos(unix_nanos: i64) -> Result<Self, GnssTimeError>
Construct from a Unix timestamp with nanosecond precision.
unix_nanos is the number of nanoseconds since 1970-01-01 00:00:00 UTC.
§Errors
Returns GnssTimeError::Overflow if the result would be before the
UTC epoch (1972-01-01), i.e. unix_nanos < UTC_EPOCH_UNIX_OFFSET_NS.
§Example
use gnss_time::{Time, Utc, UTC_EPOCH_UNIX_OFFSET_NS};
// UTC epoch in Unix nanoseconds
let utc = Time::<Utc>::from_unix_nanos(UTC_EPOCH_UNIX_OFFSET_NS).unwrap();
assert_eq!(utc, Time::<Utc>::EPOCH);
// Round-trip
let nanos: i64 = 1_700_000_000_123_456_789;
let utc2 = Time::<Utc>::from_unix_nanos(nanos).unwrap();
assert_eq!(utc2.as_unix_nanos(), nanos);Sourcepub fn as_unix_seconds(self) -> i64
pub fn as_unix_seconds(self) -> i64
Returns this UTC timestamp as a Unix timestamp (whole seconds since 1970-01-01 UTC).
The result is always ≥ UTC_EPOCH_UNIX_OFFSET_S because Time<Utc>
cannot represent dates before 1972-01-01.
§Overflow behavior
If the result exceeds i64::MAX, it saturates at i64::MAX.
§Example
use gnss_time::{Time, Utc, UTC_EPOCH_UNIX_OFFSET_S};
// UTC epoch = 1972-01-01 = Unix 63_072_000
assert_eq!(
Time::<Utc>::EPOCH.as_unix_seconds(),
UTC_EPOCH_UNIX_OFFSET_S
);
// Round-trip
let unix_s: i64 = 1_700_000_000;
let utc = Time::<Utc>::from_unix_seconds(unix_s).unwrap();
assert_eq!(utc.as_unix_seconds(), unix_s);Sourcepub fn as_unix_nanos(self) -> i64
pub fn as_unix_nanos(self) -> i64
Returns this UTC timestamp as a Unix timestamp with nanosecond precision (nanoseconds since 1970-01-01 UTC).
§Overflow note
i64 can represent nanoseconds up to ~year 2262 from the Unix epoch.
For timestamps beyond that, this method saturates at i64::MAX.
In practice, Time<Utc>::MAX corresponds to ~year 2556, which is
beyond i64 range — plan accordingly.
§Example
use gnss_time::{Time, Utc, UTC_EPOCH_UNIX_OFFSET_NS};
assert_eq!(Time::<Utc>::EPOCH.as_unix_nanos(), UTC_EPOCH_UNIX_OFFSET_NS);
// Round-trip (within i64 range)
let nanos: i64 = 1_700_000_000_123_456_789;
let utc = Time::<Utc>::from_unix_nanos(nanos).unwrap();
assert_eq!(utc.as_unix_nanos(), nanos);Sourcepub fn to_gps(self) -> Result<Time<Gps>, GnssTimeError>
pub fn to_gps(self) -> Result<Time<Gps>, GnssTimeError>
Conversion of UTC time to GPS using the built-in leap seconds table.
§Errors
Returns GnssTimeError::Overflow if the conversion fails due to
arithmetic overflow during UTC → GPS transformation.
Returns GnssTimeError::LeapSecondsRequired if the conversion cannot
be resolved due to missing or inconsistent leap second data.
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>
Converts UTC time to GPS time using a custom leap seconds provider.
§Errors
Returns:
GnssTimeError::Overflowif the resulting GPS timestamp cannot be represented inu64nanosecondsGnssTimeError::LeapSecondsRequiredif the conversion cannot be resolved due to missing or invalid leap second data inls
Sourcepub fn to_civil(self) -> CivilDateTime
pub fn to_civil(self) -> CivilDateTime
Converts this UTC timestamp to a CivilDateTime.
The result expresses the instant as a human-readable date and time-of-day in the proleptic Gregorian calendar.
§Panics
Panics if converting the internal UTC nanosecond count to
CivilDateTime fails. In normal use this should not happen because
Time<Utc> is already constrained to the UTC epoch range.
§Examples
use gnss_time::{Time, Utc};
// UTC epoch = 1972-01-01T00:00:00.000000000Z
let dt = Time::<Utc>::EPOCH.to_civil();
assert_eq!(dt.to_string(), "1972-01-01T00:00:00.000000000Z");
// GPS epoch (1980-01-06) as UTC
let utc = Time::<Utc>::from_nanos(252_892_800_000_000_000);
let dt = utc.to_civil();
assert_eq!(dt.year, 1980);
assert_eq!(dt.month, 1);
assert_eq!(dt.day, 6);
assert_eq!(dt.hour, 0);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<'de, S: TimeScale> Deserialize<'de> for Time<S>
impl<'de, S: TimeScale> Deserialize<'de> for Time<S>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§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>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
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