summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2022-01-17 13:55:07 -0500
committerBotahamec <botahamec@outlook.com>2022-01-17 13:55:07 -0500
commitdc115d47955d69cd97ce5afee378508c63ccb981 (patch)
tree0541701371c2074edfe6c46017187bc96edd398e /src
parent25a361f50728b2612c96c63594eb920f7030c5f5 (diff)
naive date time
Diffstat (limited to 'src')
-rw-r--r--src/date.rs2
-rw-r--r--src/datetime.rs61
-rw-r--r--src/lib.rs4
-rw-r--r--src/time.rs10
4 files changed, 71 insertions, 6 deletions
diff --git a/src/date.rs b/src/date.rs
index 2751e53..bc2d7dd 100644
--- a/src/date.rs
+++ b/src/date.rs
@@ -37,6 +37,8 @@ impl Date {
Self { year, month, day }
}
+ // TODO docs
+
pub const fn year(self) -> Year {
self.year
}
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
diff --git a/src/lib.rs b/src/lib.rs
index 7fee16c..d3b0e30 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,12 +1,16 @@
#![doc = include_str!("../README.md")]
+// TODO must uses
+
mod date;
+mod datetime;
mod month;
mod time;
mod weekday;
mod year;
pub use date::Date;
+pub use datetime::NaiveDateTime;
pub use month::Month;
pub use time::Time;
pub use weekday::Weekday;
diff --git a/src/time.rs b/src/time.rs
index 6981c94..94f7cd8 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -1,5 +1,3 @@
-use std::ops::Add;
-
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct Time {
hour: u8,
@@ -107,14 +105,14 @@ impl Time {
// Get the millisecond within the second.
// The returned value will always be in the range `0..1_000`
- pub const fn millisecond(self) -> u8 {
- (self.nanosecond / 1_000_000) as u8
+ pub const fn millisecond(self) -> u16 {
+ (self.nanosecond / 1_000_000) as u16
}
// Get the microsecond within the second.
// The returned value will always be in the range `0..1_000_000`
- pub const fn microsecond(self) -> u8 {
- (self.nanosecond / 1_000) as u8
+ pub const fn microsecond(self) -> u32 {
+ (self.nanosecond / 1_000) as u32
}
// Get the nanosecond within the second.