Skip to content

Commit

Permalink
Fix timestamp-to-nanosecond conversion in the adapter (bytecodeallian…
Browse files Browse the repository at this point in the history
…ce#93)

The order of operations for handling the seconds/nanoseconds part of the
structure were a bit off which meant that a nonzero nanosecond field
would have an unexpected effect on the result.

Closes bytecodealliance#92
  • Loading branch information
alexcrichton authored Feb 22, 2023
1 parent 0eb8dd2 commit 9a10e85
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion host/tests/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async fn run_time(mut store: Store<WasiCtx>, wasi: WasiCommand) -> Result<()> {
}

fn now(&self) -> Duration {
Duration::from_secs(1431648000)
Duration::new(1431648000, 100)
}

fn dup(&self) -> Box<dyn WasiWallClock + Send + Sync> {
Expand Down
2 changes: 1 addition & 1 deletion test-programs/src/bin/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
assert_eq!(Duration::from_secs(42), then.elapsed());

assert_eq!(
SystemTime::UNIX_EPOCH + Duration::from_secs(1431648000),
SystemTime::UNIX_EPOCH + Duration::new(1431648000, 100),
SystemTime::now()
);
}

0 comments on commit 9a10e85

Please sign in to comment.