pub struct TaiTime<const EPOCH_REF: i64> { /* private fields */ }Expand description
Nanosecond-precision monotonic clock timestamp parametrized by its epoch.
A timestamp specifies a TAI point in time. It is represented as a 64-bit signed number of seconds and a positive number of nanoseconds, counted with reference to the epoch specified by the generic parameter.
EPOCH_REF defines the epoch via its signed distance in seconds from
1970-01-01 00:00:00 TAI.
See also: MonotonicTime, GpsTime, GstTime, BdtTime,
Tai1958Time and Tai1972Time.
§Examples
use std::time::Duration;
use tai_time::TaiTime;
// A timestamp type with an epoch at 1970:01:01 00:02:03 TAI.
type MyCustomTime = TaiTime<123>;
// A timestamp set to 2009-02-13 23:33:33.333333333 TAI.
let mut timestamp = MyCustomTime::new(1_234_567_890, 333_333_333).unwrap();
// Increment the timestamp by 123.456s.
timestamp += Duration::new(123, 456_000_000);
assert_eq!(timestamp, MyCustomTime::new(1_234_568_013, 789_333_333).unwrap());
assert_eq!(timestamp.as_secs(), 1_234_568_013);
assert_eq!(timestamp.subsec_nanos(), 789_333_333);Implementations§
source§impl<const EPOCH_REF: i64> TaiTime<EPOCH_REF>
impl<const EPOCH_REF: i64> TaiTime<EPOCH_REF>
sourcepub const fn new(secs: i64, subsec_nanos: u32) -> Option<Self>
pub const fn new(secs: i64, subsec_nanos: u32) -> Option<Self>
Creates a timestamp from its parts.
The number of seconds is relative to the epoch. The number of nanoseconds is always positive and always points towards the future.
Returns None if the number of nanoseconds is greater than 999 999 999.
§Example
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use std::time::Duration;
use tai_time::MonotonicTime;
// A timestamp set to 2009-02-13 23:31:30.987654321 TAI.
let timestamp = MonotonicTime::new(1_234_567_890, 987_654_321).unwrap();
// A timestamp set 0.5s in the past of the epoch.
let timestamp = MonotonicTime::new(-1, 500_000_000).unwrap();
assert_eq!(timestamp, MonotonicTime::EPOCH - Duration::from_millis(500));sourcepub fn now() -> Self
Available on crate feature tai_clock and (Android or Emscripten or Fuchsia or Linux) only.
pub fn now() -> Self
tai_clock and (Android or Emscripten or Fuchsia or Linux) only.Creates a timestamp from the TAI system clock.
This is currently only supported on Linux and relies on the
clock_gettime system call with a CLOCK_TAI clock ID.
The use of the Linux TAI clock is subject to several caveats, most importantly:
- On many default-configured Linux systems, the offset between TAI and UTC is arbitrarily set to 0 at boot time, in which case the TAI system clock will actually only differ from UTC time by the number of leap seconds introduced after the system was booted (most likely, 0).
- Some systems are configured to perform leap second smearing by altering the rate of the system clock over a 24h period so as to avoid the leap second discontinuity; this entirely defeats the purpose of the TAI clock which becomes effectively synchronized to the (leap-smeared) UTC system clock.
The first issue can be easily remedied, however, by using chrony and,
if necessary, making sure that the leapsectz parameter in
chrony.conf is set to right/UTC. Alternatively, one can specify the
leapfile path in ntp.conf or set the TAI offset directly with a call
to adjtimex or ntp_adjtime.
§Panics
Panics if the result is outside the representable range for the
resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch.
See try_now for a non-panicking alternative.
Note that this constructor will never fail with the MonotonicTime
alias as it shares the same epoch as the TAI system clock.
sourcepub fn try_now() -> Result<Self, OutOfRangeError>
Available on crate feature tai_clock and (Android or Emscripten or Fuchsia or Linux) only.
pub fn try_now() -> Result<Self, OutOfRangeError>
tai_clock and (Android or Emscripten or Fuchsia or Linux) only.Creates a timestamp from the TAI system clock.
This is a non-panicking alternative to now.
When using the MonotonicTime alias, use now since it
will never fail.
Returns an error if the result is outside the representable range for
the resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch.
sourcepub fn now_from_utc(leap_secs: i64) -> Self
Available on crate feature std only.
pub fn now_from_utc(leap_secs: i64) -> Self
std only.Creates a timestamp from the UTC system clock.
This is a shorthand for from_system_time(&SystemTime::now(), leap_secs).
The argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.
Beware that the behavior of the system clock near a leap second shouldn’t be relied upon, where near might actually stand for the whole 24h period preceding a leap second due to the possible use of the so-called leap second smearing strategy.
See also: from_system_time.
§Panics
Panics if the result is outside the representable range for the
resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch.
See try_now_from_utc for a non-panicking
alternative.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use tai_time::MonotonicTime;
// Compute the current timestamp assuming that the current difference
// between TAI and UTC time is 37s.
let timestamp = MonotonicTime::now_from_utc(37);sourcepub fn try_now_from_utc(leap_secs: i64) -> Result<Self, OutOfRangeError>
Available on crate feature std only.
pub fn try_now_from_utc(leap_secs: i64) -> Result<Self, OutOfRangeError>
std only.Creates a timestamp from the UTC system clock.
This is a non-panicking alternative to now_from_utc.
Returns an error if the result is outside the representable range for
the resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch.
sourcepub const fn try_from_date_time(
year: i32,
month: u8,
day: u8,
hour: u8,
min: u8,
sec: u8,
nano: u32
) -> Result<Self, DateTimeError>
pub const fn try_from_date_time( year: i32, month: u8, day: u8, hour: u8, min: u8, sec: u8, nano: u32 ) -> Result<Self, DateTimeError>
Creates a timestamp from a date-time representation.
The first argument is the proleptic Gregorian year. It follows the ISO 8601 interpretation of year 0 as year 1 BC.
Other arguments follow the usual calendar convention, with month and day numerals starting at 1.
Note that the proleptic Gregorian calendar extrapolates dates before 1582 using the conventional leap year rules, and considers year 0 as a leap year. Proleptic Gregorian dates may therefore differ from those of the Julian calendar.
Returns an error if any of the arguments is invalid, or if the calculated timestamp is outside the representable range.
May also return an error if the result is outside the representable
range for the resulting timestamp. This is a highly unlikely occurrence
since the range of a TaiTime spans more than ±292 billion years from
its epoch, and is impossible with the provided TaiTime aliases
(MonotonicTime, GpsTime, GstTime, BdtTime,
Tai1958Time or Tai1972Time).
§Example
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use std::time::Duration;
use tai_time::MonotonicTime;
// A timestamp set to 2009-02-13 23:31:30.987654321 TAI.
let timestamp = MonotonicTime::try_from_date_time(2009, 2, 13, 23, 31, 30, 987_654_321);
assert_eq!(timestamp, Ok(MonotonicTime::new(1_234_567_890, 987_654_321).unwrap()));sourcepub const fn from_unix_timestamp(
secs: i64,
subsec_nanos: u32,
leap_secs: i64
) -> Self
pub const fn from_unix_timestamp( secs: i64, subsec_nanos: u32, leap_secs: i64 ) -> Self
Creates a TAI timestamp from a Unix timestamp.
The last argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.
This method tolerates Unix timestamps that account for leap seconds by adding them to the nanosecond field: all nanoseconds in excess of 999 999 999 will carry over into the seconds.
Note that there is no unanimous consensus regarding the conversion between TAI and Unix timestamps prior to 1972.
§Panics
Panics if the result is outside the representable range for the
resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch.
See try_from_unix_timestamp for a
non-panicking alternative.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use tai_time::MonotonicTime;
// Creates a timestamp corresponding to 2001-09-15 05:05:00.005 UTC,
// accounting for the +32s difference between UAI and UTC on 2001-09-15.
assert_eq!(
MonotonicTime::from_unix_timestamp(1_000_530_300, 5_000_000, 32),
MonotonicTime::new(1_000_530_332, 5_000_000).unwrap()
);sourcepub const fn try_from_unix_timestamp(
secs: i64,
subsec_nanos: u32,
leap_secs: i64
) -> Result<Self, OutOfRangeError>
pub const fn try_from_unix_timestamp( secs: i64, subsec_nanos: u32, leap_secs: i64 ) -> Result<Self, OutOfRangeError>
Creates a TAI timestamp from a Unix timestamp.
This is a non-panicking alternative to from_unix_timestamp.
Returns an error if the result is outside the representable range for
the resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch.
sourcepub fn from_system_time(system_time: &SystemTime, leap_secs: i64) -> Self
Available on crate feature std only.
pub fn from_system_time(system_time: &SystemTime, leap_secs: i64) -> Self
std only.Creates a TAI timestamp from a SystemTime timestamp.
The last argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.
§Panics
Panics if the result is outside the representable range for the
resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch.
See try_from_system_time for a
non-panicking alternative.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use std::time::{Duration, SystemTime};
use tai_time::MonotonicTime;
// Creates a timestamp corresponding to 2001-09-15 05:05:00.005 UTC,
// accounting for the +32s difference between UAI and UTC on 2001-09-15.
let system_time = SystemTime::UNIX_EPOCH + Duration::new(1_000_530_300, 5_000_000);
assert_eq!(
MonotonicTime::from_system_time(&system_time, 32),
MonotonicTime::new(1_000_530_332, 5_000_000).unwrap()
);sourcepub fn try_from_system_time(
system_time: &SystemTime,
leap_secs: i64
) -> Result<Self, OutOfRangeError>
Available on crate feature std only.
pub fn try_from_system_time( system_time: &SystemTime, leap_secs: i64 ) -> Result<Self, OutOfRangeError>
std only.Creates a TAI timestamp from a SystemTime timestamp.
This is a non-panicking alternative to
from_system_time.
Returns an error if the result is outside the representable range for
the resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch.
sourcepub const fn from_chrono_date_time<Tz: TimeZone>(
date_time: &DateTime<Tz>,
leap_secs: i64
) -> Self
Available on crate feature chrono only.
pub const fn from_chrono_date_time<Tz: TimeZone>( date_time: &DateTime<Tz>, leap_secs: i64 ) -> Self
chrono only.Creates a timestamp from a chrono::DateTime.
The argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.
While no error will be reported, this method should not be considered appropriate for timestamps in the past of 1972.
§Panics
Panics if the result is outside the representable range for the
resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch
while the range of a chrono::DateTime spans from year -262144 to year
262143.
See try_from_chrono_date_time for a
non-panicking alternative.
Note that the conversion will never fail with the provided TaiTime
aliases (MonotonicTime, GpsTime, GstTime, BdtTime,
Tai1958Time or Tai1972Time).
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use tai_time::MonotonicTime;
use chrono::DateTime;
let tai_date_time: MonotonicTime = "2001-09-15 05:05:32.005".parse().unwrap();
let chrono_date_time = DateTime::parse_from_rfc3339("2001-09-15T05:05:00.005Z").unwrap();
assert_eq!(
MonotonicTime::from_chrono_date_time(&chrono_date_time, 32),
tai_date_time
);sourcepub const fn try_from_chrono_date_time<Tz: TimeZone>(
date_time: &DateTime<Tz>,
leap_secs: i64
) -> Result<Self, OutOfRangeError>
Available on crate feature chrono only.
pub const fn try_from_chrono_date_time<Tz: TimeZone>( date_time: &DateTime<Tz>, leap_secs: i64 ) -> Result<Self, OutOfRangeError>
chrono only.Creates a timestamp from a chrono::DateTime.
This is a non-panicking alternative to
from_chrono_date_time.
When using the provided TaiTime aliases (MonotonicTime,
GpsTime, GstTime, BdtTime, Tai1958Time or
Tai1972Time), use
from_chrono_date_time since the
conversion will never fail.
Returns an error if the result is outside the representable range for
the resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch
while the range of a chrono::DateTime spans from year -262144 to year
262143.
sourcepub const fn as_secs(&self) -> i64
pub const fn as_secs(&self) -> i64
Returns the signed value of the closest second boundary that is equal to
or lower than the timestamp, relative to the EPOCH.
This value is the same as the one that would be provided to construct
the timestamp with new().
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use std::time::Duration;
use tai_time::MonotonicTime;
let timestamp = MonotonicTime::new(1_234_567_890, 987_654_321).unwrap();
assert_eq!(timestamp.as_secs(), 1_234_567_890);
let timestamp = MonotonicTime::EPOCH - Duration::new(3, 500_000_000);
assert_eq!(timestamp.as_secs(), -4);sourcepub const fn subsec_nanos(&self) -> u32
pub const fn subsec_nanos(&self) -> u32
Returns the sub-second fractional part in nanoseconds.
Note that nanoseconds always point towards the future even if the date
is in the past of the EPOCH.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use tai_time::MonotonicTime;
let timestamp = MonotonicTime::new(1_234_567_890, 987_654_321).unwrap();
assert_eq!(timestamp.subsec_nanos(), 987_654_321);sourcepub const fn as_unix_secs(&self, leap_secs: i64) -> Option<i64>
pub const fn as_unix_secs(&self, leap_secs: i64) -> Option<i64>
Returns the number of seconds of the corresponding Unix timestamp.
The argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.
This method merely subtracts the offset from the value returned by
as_secs(); its main purpose is to prevent mistakes
regarding the direction in which the offset should be applied.
The nanosecond part of a Unix timestamp can be simply retrieved with
subsec_nanos() since UTC and TAI differ by a
whole number of seconds since 1972.
Note that there is no unanimous consensus regarding the conversion between TAI and Unix timestamps prior to 1972.
Returns None if the result cannot be represented as a Unix timestamp.
This is a highly unlikely occurrence since the range of a Unix timestamp
spans more than ±292 billion years from 1970-01-01 00:00:00 UTC.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use tai_time::MonotonicTime;
// Set the date to 2000-01-01 00:00:00 TAI.
let timestamp = MonotonicTime::new(946_684_800, 0).unwrap();
// Convert to a Unix timestamp, accounting for the +32s difference between
// TAI and UTC on 2000-01-01.
assert_eq!(
timestamp.as_unix_secs(32),
Some(946_684_768)
);sourcepub const fn to_tai_time<const OTHER_EPOCH_REF: i64>(
&self
) -> Option<TaiTime<OTHER_EPOCH_REF>>
pub const fn to_tai_time<const OTHER_EPOCH_REF: i64>( &self ) -> Option<TaiTime<OTHER_EPOCH_REF>>
Returns a timestamp with a different reference epoch.
Returns None if the result is outside the representable range for the
resulting timestamp. This is a highly unlikely occurrence since the
range of a TaiTime spans more than ±292 billion years from its epoch.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use tai_time::{GpsTime, MonotonicTime};
// Set the date to 2000-01-01 00:00:00 TAI.
let timestamp = MonotonicTime::new(946_684_800, 0).unwrap();
// Convert to a GPS timestamp.
let gps_timestamp: GpsTime = timestamp.to_tai_time().unwrap();
assert_eq!(
gps_timestamp,
GpsTime::new(630_719_981, 0).unwrap()
);sourcepub fn to_system_time(&self, leap_secs: i64) -> Option<SystemTime>
Available on crate feature std only.
pub fn to_system_time(&self, leap_secs: i64) -> Option<SystemTime>
std only.Returns a SystemTime based on the timestamp.
The argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.
While no error will be reported, this method should not be considered appropriate for timestamps in the past of 1972.
Returns None if the resulting timestamp predates the Unix epoch
(1970-01-01 00:00:00 UTC) or cannot be otherwise represented as a
SystemTime.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use std::time::{Duration, SystemTime};
use tai_time::MonotonicTime;
// Set the date to 2000-01-01 00:00:00.123 TAI.
let timestamp = MonotonicTime::new(946_684_800, 123_000_000).unwrap();
// Obtain a `SystemTime`, accounting for the +32s difference between
// TAI and UTC on 2000-01-01.
assert_eq!(
timestamp.to_system_time(32),
Some(SystemTime::UNIX_EPOCH + Duration::new(946_684_768, 123_000_000))
);sourcepub fn to_chrono_date_time(&self, leap_secs: i64) -> Option<DateTime<Utc>>
Available on crate feature chrono only.
pub fn to_chrono_date_time(&self, leap_secs: i64) -> Option<DateTime<Utc>>
chrono only.Returns a chrono::DateTime based on the timestamp.
The argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.
While no error will be reported, this method should not be considered appropriate for timestamps in the past of 1972.
Returns None if the resulting timestamp cannot be represented by a
chrono::DateTime, which may occur if the date predates year -262144 or
postdates year 262143.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use tai_time::MonotonicTime;
// Set the date to 2000-01-01 00:00:00.123 TAI (1999-12-31 23:59:28.123 UTC).
let timestamp = MonotonicTime::new(946_684_800, 123_000_000).unwrap();
// Obtain a `chrono::DateTime`, accounting for the +32s difference between
// TAI and UTC on 2000-01-01.
let date_time = timestamp.to_chrono_date_time(32).unwrap();
assert_eq!(
date_time.to_string(),
"1999-12-31 23:59:28.123 UTC"
);sourcepub const fn checked_add(self, rhs: Duration) -> Option<Self>
pub const fn checked_add(self, rhs: Duration) -> Option<Self>
Adds a duration to a timestamp, checking for overflow.
Returns None if overflow occurred.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use std::time::Duration;
use tai_time::MonotonicTime;
let timestamp = MonotonicTime::new(1_234_567_890, 987_654_321).unwrap();
assert!(timestamp.checked_add(Duration::new(10, 123_456_789)).is_some());
assert!(timestamp.checked_add(Duration::MAX).is_none());sourcepub const fn checked_sub(self, rhs: Duration) -> Option<Self>
pub const fn checked_sub(self, rhs: Duration) -> Option<Self>
Subtracts a duration from a timestamp, checking for overflow.
Returns None if overflow occurred.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use std::time::Duration;
use tai_time::MonotonicTime;
let timestamp = MonotonicTime::new(1_234_567_890, 987_654_321).unwrap();
assert!(timestamp.checked_sub(Duration::new(10, 123_456_789)).is_some());
assert!(timestamp.checked_sub(Duration::MAX).is_none());sourcepub const fn duration_since(self, earlier: Self) -> Duration
pub const fn duration_since(self, earlier: Self) -> Duration
Subtracts a timestamp from another timestamp.
Consider using checked_duration_since
if the relative ordering of the timestamps is not known with certainty.
§Panics
Panics if the argument lies in the future of self.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use std::time::Duration;
use tai_time::MonotonicTime;
let timestamp_earlier = MonotonicTime::new(1_234_567_879, 987_654_321).unwrap();
let timestamp_later = MonotonicTime::new(1_234_567_900, 123_456_789).unwrap();
assert_eq!(
timestamp_later.duration_since(timestamp_earlier),
Duration::new(20, 135_802_468)
);sourcepub const fn checked_duration_since(self, earlier: Self) -> Option<Duration>
pub const fn checked_duration_since(self, earlier: Self) -> Option<Duration>
Computes the duration elapsed between a timestamp and an earlier timestamp, checking that the timestamps are appropriately ordered.
Returns None if the argument lies in the future of self.
§Examples
(Shown here for MonotonicTime, an alias for TaiTime<0>)
use std::time::Duration;
use tai_time::MonotonicTime;
let timestamp_earlier = MonotonicTime::new(1_234_567_879, 987_654_321).unwrap();
let timestamp_later = MonotonicTime::new(1_234_567_900, 123_456_789).unwrap();
assert!(timestamp_later.checked_duration_since(timestamp_earlier).is_some());
assert!(timestamp_earlier.checked_duration_since(timestamp_later).is_none());Trait Implementations§
source§impl<const EPOCH_REF: i64> AddAssign<Duration> for TaiTime<EPOCH_REF>
impl<const EPOCH_REF: i64> AddAssign<Duration> for TaiTime<EPOCH_REF>
source§fn add_assign(&mut self, other: Duration)
fn add_assign(&mut self, other: Duration)
Increments the timestamp by a duration.
§Panics
This function panics if the resulting timestamp cannot be represented.
source§impl<'de, const EPOCH_REF: i64> Deserialize<'de> for TaiTime<EPOCH_REF>
impl<'de, const EPOCH_REF: i64> Deserialize<'de> for TaiTime<EPOCH_REF>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<const EPOCH_REF: i64> FromStr for TaiTime<EPOCH_REF>
impl<const EPOCH_REF: i64> FromStr for TaiTime<EPOCH_REF>
source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses an RFC3339-like TAI date-time with signed years. Since TAI is timezone-independent, time zones and offsets suffixes are invalid.
Expected format:
[±][Y]...[Y]YYYY-MM-DD hh:mm:ss[.d[d]...[d]]
or:
[±][Y]...[Y]YYYY-MM-DD'T'hh:mm:ss[.d[d]...[d]]
where delimiter T between date and time may also be a lowercase t.
The year may take any value within ±i32::MAX.
§type Err = ParseDateTimeError
type Err = ParseDateTimeError
source§impl<const EPOCH_REF: i64> Ord for TaiTime<EPOCH_REF>
impl<const EPOCH_REF: i64> Ord for TaiTime<EPOCH_REF>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<const EPOCH_REF: i64> PartialEq for TaiTime<EPOCH_REF>
impl<const EPOCH_REF: i64> PartialEq for TaiTime<EPOCH_REF>
source§impl<const EPOCH_REF: i64> PartialOrd for TaiTime<EPOCH_REF>
impl<const EPOCH_REF: i64> PartialOrd for TaiTime<EPOCH_REF>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl<const EPOCH_REF: i64> Sub<Duration> for TaiTime<EPOCH_REF>
impl<const EPOCH_REF: i64> Sub<Duration> for TaiTime<EPOCH_REF>
source§impl<const EPOCH_REF: i64> SubAssign<Duration> for TaiTime<EPOCH_REF>
impl<const EPOCH_REF: i64> SubAssign<Duration> for TaiTime<EPOCH_REF>
source§fn sub_assign(&mut self, other: Duration)
fn sub_assign(&mut self, other: Duration)
Decrements the timestamp by a duration.
§Panics
This function panics if the resulting timestamp cannot be represented.