Skip to content

Commit

Permalink
Merge #1801
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bors[bot] and StephanvanSchaik committed Aug 21, 2022
2 parents 2a8b438 + 7109eb9 commit 82fe82a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/sys/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 82fe82a

Please sign in to comment.