diff options
| author | Botahamec <botahamec@outlook.com> | 2022-01-31 10:03:59 -0500 |
|---|---|---|
| committer | Botahamec <botahamec@outlook.com> | 2022-01-31 10:03:59 -0500 |
| commit | 81f29c5fd9e9ca7b59fe26c0d647890922c4bde2 (patch) | |
| tree | 53e7c45380b1134eeccb92a08ef61598f9add43a /src/datetime.rs | |
| parent | 2a057c1197d70d1d9b31a090c28dd7b929fdb6ae (diff) | |
Implemented default formatting
Diffstat (limited to 'src/datetime.rs')
| -rw-r--r-- | src/datetime.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/datetime.rs b/src/datetime.rs index 282a56b..f856e74 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -3,7 +3,7 @@ use crate::{ Date, Month, Time, TimeZone, Year, }; -use core::{cmp::Ordering, hash::Hash}; +use core::{cmp::Ordering, fmt::Display, hash::Hash}; #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct NaiveDateTime { @@ -150,3 +150,15 @@ impl<Tz: TimeZone> Ord for DateTime<Tz> { } // TODO addition + +impl Display for NaiveDateTime { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{} {}", self.date, self.time) + } +} + +impl<Tz: TimeZone> Display for DateTime<Tz> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{} {}", self.utc_datetime, self.timezone) + } +} |
