Skip to content

Commit

Permalink
0.1.11
Browse files Browse the repository at this point in the history
divi255 committed Apr 19, 2024
1 parent fc13888 commit 85df382
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bma-ts"
version = "0.1.10"
version = "0.1.11"
edition = "2021"
authors = ["Serhij S. <[email protected]>"]
license = "MIT"
4 changes: 4 additions & 0 deletions src/monotonic.rs
Original file line number Diff line number Diff line change
@@ -45,4 +45,8 @@ impl Monotonic {
pub fn elapsed(&self) -> Duration {
Self::now().0 - self.0
}
#[inline]
pub fn duration_since(&self, earlier: Self) -> Duration {
self.0 - earlier.0
}
}
8 changes: 8 additions & 0 deletions src/timestamp.rs
Original file line number Diff line number Diff line change
@@ -31,6 +31,14 @@ impl Timestamp {
Err(Error::TimeWentBackward)
}
}
#[inline]
pub fn duration_since(self, earlier: Self) -> Result<Duration, Error> {
if self >= earlier {
Ok(self.0 - earlier.0)
} else {
Err(Error::TimeWentBackward)
}
}
/// Converts between ANSI (Windows, 1601-01-01) and UNIX (1970-01-01) timestamps
/// The source timestamp MUST be in nanoseconds (for Windows timestamp - multiply the source by
/// 100)

0 comments on commit 85df382

Please sign in to comment.