summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-08-21 00:52:41 +0000
committerGitHub <noreply@github.com>2022-08-21 00:52:41 +0000
commit82fe82ad53206900c95a0a87c8472d49536143fa (patch)
tree7a57a0f14cf0e4547dd1fdb6e842d7f36f3534a4
parent2a8b438860ed37d515ed2cf854a9cd7cfaef35d5 (diff)
parent7109eb9d2e953f40ee0bbf79e8d427e8dd059930 (diff)
downloadnix-82fe82ad53206900c95a0a87c8472d49536143fa.zip
Merge #1801
1801: fix microsecond calculation for TimeSpec r=rtzoeller a=StephanvanSchaik The implementation of `num_microseconds()` for `TimeSpec` returns the number of seconds not microseconds, as it divided by the wrong factor. The number of nanoseconds should be divided by 1000 to get the number of microseconds. Co-authored-by: S.J.R. van Schaik <stephan@synkhronix.com>
-rw-r--r--CHANGELOG.md3
-rw-r--r--src/sys/time.rs2
2 files changed, 4 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 56ab09ff..2e383277 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
### Fixed
+- Fix microsecond calculation for `TimeSpec`.
+ ([#1801](https://github.com/nix-rust/nix/pull/1801))
+
### Removed
## [0.25.0] - 2022-08-13
diff --git a/src/sys/time.rs b/src/sys/time.rs
index 0cac7e8a..da65d516 100644
--- a/src/sys/time.rs
+++ b/src/sys/time.rs
@@ -319,7 +319,7 @@ impl TimeValLike for TimeSpec {
}
fn num_microseconds(&self) -> i64 {
- self.num_nanoseconds() / 1_000_000_000
+ self.num_nanoseconds() / 1_000
}
fn num_nanoseconds(&self) -> i64 {