diff options
| author | Botahamec <botahamec@outlook.com> | 2022-03-22 17:42:44 -0400 |
|---|---|---|
| committer | Botahamec <botahamec@outlook.com> | 2022-03-22 17:42:44 -0400 |
| commit | ff715d1d53f9f84c95327096cc839cdc4c965645 (patch) | |
| tree | cd404f5c0f2d491376a97390371dbb6fdeacfb63 /src/timestamp.rs | |
| parent | cf2673d4d4bc8d6b96f4488847d8c2b3c3545010 (diff) | |
Renamed UnixTimestamp
Diffstat (limited to 'src/timestamp.rs')
| -rw-r--r-- | src/timestamp.rs | 12 |
1 files changed, 6 insertions, 6 deletions
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<NaiveDateTime> for UnixTimestamp { +impl From<NaiveDateTime> 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<NaiveDateTime> for UnixTimestamp { } } -impl PartialOrd for UnixTimestamp { +impl PartialOrd for Timestamp { fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> { 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), |
