summaryrefslogtreecommitdiff
path: root/src/datetime.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/datetime.rs')
-rw-r--r--src/datetime.rs31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/datetime.rs b/src/datetime.rs
index 54685ec..c739d46 100644
--- a/src/datetime.rs
+++ b/src/datetime.rs
@@ -1,4 +1,4 @@
-use crate::{Date, Month, Time, Year};
+use crate::{timezone::UtcOffset, Date, Month, Time, TimeZone, Year};
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct NaiveDateTime {
@@ -6,6 +6,35 @@ pub struct NaiveDateTime {
time: Time,
}
+#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+pub struct DateTime<Tz: TimeZone> {
+ utc_datetime: NaiveDateTime,
+ timezone: Tz,
+}
+
+impl<Tz: TimeZone> DateTime<Tz> {
+ // TODO unix epoch constant
+
+ pub fn from_utc(utc_datetime: NaiveDateTime, timezone: Tz) -> Self {
+ Self {
+ utc_datetime,
+ timezone,
+ }
+ }
+
+ pub fn offset(&self) -> UtcOffset {
+ self.timezone.utc_offset(self.utc_datetime)
+ }
+
+ pub fn timezone(&self) -> &Tz {
+ &self.timezone
+ }
+
+ pub fn naive_utc(&self) -> NaiveDateTime {
+ self.utc_datetime
+ }
+}
+
impl NaiveDateTime {
// TODO docs