pub struct UtcUnixNanos(pub i128);Expand description
Unix-epoch nanoseconds in the UTC scale.
Uses i128 to hold the full range of Unix nanoseconds without overflow.
Promote from UtcUnixSeconds via .into(), truncate back with
to_seconds_floor.
§Example
use leap_sec::{UtcUnixSeconds, UtcUnixNanos};
let ns = UtcUnixNanos(1_700_000_000_500_000_000);
assert_eq!(format!("{ns}"), "1700000000500000000 UTC");
// Promote from seconds
let promoted: UtcUnixNanos = UtcUnixSeconds(1_700_000_000).into();
assert_eq!(promoted, UtcUnixNanos(1_700_000_000_000_000_000));Tuple Fields§
§0: i128Implementations§
Source§impl UtcUnixNanos
impl UtcUnixNanos
Sourcepub const fn to_seconds_floor(self) -> UtcUnixSeconds
pub const fn to_seconds_floor(self) -> UtcUnixSeconds
Truncate to whole seconds, rounding toward negative infinity.
§Example
use leap_sec::{UtcUnixSeconds, UtcUnixNanos};
let ns = UtcUnixNanos(1_700_000_000_999_999_999);
assert_eq!(ns.to_seconds_floor(), UtcUnixSeconds(1_700_000_000));
// Negative values floor correctly
assert_eq!(UtcUnixNanos(-1).to_seconds_floor(), UtcUnixSeconds(-1));Trait Implementations§
Source§impl Clone for UtcUnixNanos
impl Clone for UtcUnixNanos
Source§fn clone(&self) -> UtcUnixNanos
fn clone(&self) -> UtcUnixNanos
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UtcUnixNanos
impl Debug for UtcUnixNanos
Source§impl Display for UtcUnixNanos
Displays as "{nanoseconds} UTC" (e.g., "1700000000500000000 UTC").
impl Display for UtcUnixNanos
Displays as "{nanoseconds} UTC" (e.g., "1700000000500000000 UTC").
Source§impl From<UtcUnixSeconds> for UtcUnixNanos
Lossless promotion: multiplies by 1,000,000,000.
impl From<UtcUnixSeconds> for UtcUnixNanos
Lossless promotion: multiplies by 1,000,000,000.
Source§fn from(s: UtcUnixSeconds) -> Self
fn from(s: UtcUnixSeconds) -> Self
Converts to this type from the input type.
Source§impl Hash for UtcUnixNanos
impl Hash for UtcUnixNanos
Source§impl Ord for UtcUnixNanos
impl Ord for UtcUnixNanos
Source§fn cmp(&self, other: &UtcUnixNanos) -> Ordering
fn cmp(&self, other: &UtcUnixNanos) -> Ordering
1.21.0 · 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
Source§impl PartialEq for UtcUnixNanos
impl PartialEq for UtcUnixNanos
Source§impl PartialOrd for UtcUnixNanos
impl PartialOrd for UtcUnixNanos
impl Copy for UtcUnixNanos
impl Eq for UtcUnixNanos
impl StructuralPartialEq for UtcUnixNanos
Auto Trait Implementations§
impl Freeze for UtcUnixNanos
impl RefUnwindSafe for UtcUnixNanos
impl Send for UtcUnixNanos
impl Sync for UtcUnixNanos
impl Unpin for UtcUnixNanos
impl UnsafeUnpin for UtcUnixNanos
impl UnwindSafe for UtcUnixNanos
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