pub struct Timestamp(/* private fields */);Expand description
A FIT date_time: whole seconds since 1989-12-31T00:00:00Z.
use fit_encoder::Timestamp;
let t = Timestamp::from_unix(1_764_547_200).unwrap(); // 2025-12-01T00:00:00Z
assert_eq!(t.fit(), 1_133_481_600);
assert_eq!(t.unix(), 1_764_547_200);
assert_eq!(Timestamp::from_unix(0), None);Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const FIRST_DATE: Self
pub const FIRST_DATE: Self
The first FIT second read as a date; readers take any earlier one as seconds since the device started (Garmin, “Working with Date Time Values”).
Sourcepub const fn from_fit(seconds: u32) -> Self
pub const fn from_fit(seconds: u32) -> Self
A time as FIT seconds: a date from Timestamp::FIRST_DATE, or seconds since the
device started before it. u32::MAX is FIT’s “none”, which writing refuses.
Sourcepub const fn from_unix(seconds: i64) -> Option<Self>
pub const fn from_unix(seconds: i64) -> Option<Self>
A Unix time in seconds, or None before Timestamp::FIRST_DATE
(1998-07-03T21:24:16Z) or from 2126-02-06T06:28:15Z, when FIT seconds reach u32::MAX.
Sourcepub fn from_system_time(t: SystemTime) -> Option<Self>
Available on crate feature std only.
pub fn from_system_time(t: SystemTime) -> Option<Self>
std only.A system time, to the second below it, or None outside Timestamp::from_unix’s
range.
Sourcepub const fn checked_add(self, seconds: u32) -> Option<Self>
pub const fn checked_add(self, seconds: u32) -> Option<Self>
The time seconds later, or None if that reaches u32::MAX, the invalid value.
Trait Implementations§
impl Copy for Timestamp
impl Eq for Timestamp
Source§impl Ord for Timestamp
impl Ord for Timestamp
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Forget for Timestamp
impl Freeze for Timestamp
impl Move for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnsafeUnpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more