From ff715d1d53f9f84c95327096cc839cdc4c965645 Mon Sep 17 00:00:00 2001 From: Botahamec Date: Tue, 22 Mar 2022 17:42:44 -0400 Subject: Renamed UnixTimestamp --- src/timestamp.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/timestamp.rs') diff --git a/src/timestamp.rs b/src/timestamp.rs index c223ccb..08944aa 100644 --- a/src/timestamp.rs +++ b/src/timestamp.rs @@ -1,12 +1,12 @@ use crate::{Date, NaiveDateTime}; #[derive(Clone, Copy, Eq, PartialEq, Hash, Debug)] -pub struct UnixTimestamp { +pub struct Timestamp { seconds: i64, nanoseconds: u32, } -impl UnixTimestamp { +impl Timestamp { #[must_use] pub const fn new(seconds: i64, nanoseconds: u32) -> Self { Self { @@ -16,7 +16,7 @@ impl UnixTimestamp { } #[must_use] - pub const fn seconds_since_unix_epoch(self) -> i64 { + pub const fn total_seconds(self) -> i64 { self.seconds } @@ -72,7 +72,7 @@ impl UnixTimestamp { } } -impl From for UnixTimestamp { +impl From for Timestamp { fn from(ndt: NaiveDateTime) -> Self { const UNIX_EPOCH_DAYS: i64 = Date::UNIX_EPOCH.days_after_common_era(); // TODO don't require the .date() @@ -84,7 +84,7 @@ impl From for UnixTimestamp { } } -impl PartialOrd for UnixTimestamp { +impl PartialOrd for Timestamp { fn partial_cmp(&self, other: &Self) -> Option { match self.seconds.partial_cmp(&other.seconds) { Some(core::cmp::Ordering::Equal) => self.nanoseconds.partial_cmp(&other.nanoseconds), @@ -93,7 +93,7 @@ impl PartialOrd for UnixTimestamp { } } -impl Ord for UnixTimestamp { +impl Ord for Timestamp { fn cmp(&self, other: &Self) -> core::cmp::Ordering { match self.seconds.cmp(&other.seconds) { core::cmp::Ordering::Equal => self.nanoseconds.cmp(&other.nanoseconds), -- cgit v1.2.3