From dc115d47955d69cd97ce5afee378508c63ccb981 Mon Sep 17 00:00:00 2001 From: Botahamec Date: Mon, 17 Jan 2022 13:55:07 -0500 Subject: naive date time --- src/datetime.rs | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/datetime.rs (limited to 'src/datetime.rs') diff --git a/src/datetime.rs b/src/datetime.rs new file mode 100644 index 0000000..54685ec --- /dev/null +++ b/src/datetime.rs @@ -0,0 +1,61 @@ +use crate::{Date, Month, Time, Year}; + +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +pub struct NaiveDateTime { + date: Date, + time: Time, +} + +impl NaiveDateTime { + // TODO docs + + pub const fn new(date: Date, time: Time) -> Self { + Self { date, time } + } + + pub const fn date(self) -> Date { + self.date + } + + pub const fn time(self) -> Time { + self.time + } + + pub const fn year(self) -> Year { + self.date.year() + } + + pub const fn month(self) -> Month { + self.date.month() + } + + pub const fn day(self) -> u8 { + self.date.day() + } + + pub const fn hour(self) -> u8 { + self.time.hour() + } + + pub const fn minute(self) -> u8 { + self.time.minute() + } + + pub const fn second(self) -> u8 { + self.time.second() + } + + pub const fn millisecond(self) -> u16 { + self.time.millisecond() + } + + pub const fn microsecond(self) -> u32 { + self.time.microsecond() + } + + pub const fn nanosecond(self) -> u32 { + self.time.nanosecond() + } +} + +// TODO addition -- cgit v1.2.3