Skip to content

Commit

Permalink
feat: gix-date Time local_time helper and Sub implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dvtkrlbs committed Oct 24, 2024
1 parent db5c9cf commit be85c20
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions gix-date/src/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ mod sign {
}

mod impls {
use std::ops::Sub;
use crate::{time::Sign, Time};

impl Default for Time {
Expand All @@ -76,4 +77,18 @@ mod impls {
}
}
}

impl Sub for Time {
type Output = i64;

fn sub(self, rhs: Self) -> Self::Output {
self.local_time() - rhs.local_time()
}
}

impl Time {
fn local_time(&self) -> i64 {
self.seconds + self.offset as i64
}
}
}

0 comments on commit be85c20

Please sign in to comment.