Skip to content

Commit 2fed5b0

Browse files
committed
feat: gix-date Time local_time helper and Sub implementation
1 parent db5c9cf commit 2fed5b0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

gix-date/src/time/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ mod sign {
6666

6767
mod impls {
6868
use crate::{time::Sign, Time};
69+
use std::ops::Sub;
6970

7071
impl Default for Time {
7172
fn default() -> Self {
@@ -76,4 +77,18 @@ mod impls {
7677
}
7778
}
7879
}
80+
81+
impl Sub for Time {
82+
type Output = i64;
83+
84+
fn sub(self, rhs: Self) -> Self::Output {
85+
self.local_time() - rhs.local_time()
86+
}
87+
}
88+
89+
impl Time {
90+
fn local_time(&self) -> i64 {
91+
self.seconds + self.offset as i64
92+
}
93+
}
7994
}

0 commit comments

Comments
 (0)