diff options
| author | Botahamec <botahamec@outlook.com> | 2022-03-03 20:18:06 -0500 |
|---|---|---|
| committer | Botahamec <botahamec@outlook.com> | 2022-03-03 20:18:06 -0500 |
| commit | 0fb870509821eb6f8158a9ee3cc02e6a0f951c86 (patch) | |
| tree | 74cbd12648e03e39abd50a1c67dafce3526f7870 /src/datetime.rs | |
| parent | 5a4a0a5441bfd3fa590d45278e712ce24c5fa5df (diff) | |
Started with leap seconds
Diffstat (limited to 'src/datetime.rs')
| -rw-r--r-- | src/datetime.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/datetime.rs b/src/datetime.rs index f856e74..df4e637 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -92,6 +92,26 @@ impl NaiveDateTime { pub const fn nanosecond(self) -> u32 { self.time.nanosecond() } + + #[must_use] + pub fn add_seconds(self, seconds: isize) -> Self { + let time = self.time.add_seconds(seconds); + + Self { + date: self.date, + time, + } + } + + #[must_use] + pub fn add_nanoseconds(self, nanoseconds: isize) -> Self { + let time = self.time.add_nanoseconds(nanoseconds); + + Self { + date: self.date, + time, + } + } } impl PartialOrd for NaiveDateTime { |
