Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 932 Bytes

File metadata and controls

30 lines (21 loc) · 932 Bytes

Windows time types

The windows-time crate provides Windows TimeSpan and DateTime values with Rust constructors, arithmetic, and std::time conversions.

TimeSpan is a duration and DateTime is a point in time. Both use 100-nanosecond ticks.

Start by adding the following to your Cargo.toml file:

[dependencies.windows-time]
version = "0.100"

Use the time types as needed:

use windows_time::*;

let span = TimeSpan::from_minutes(90);
assert_eq!(span.whole_seconds(), 5400);

let start = DateTime::from_unix_secs(1_000_000_000);
let later = start.checked_add(span).unwrap();
assert_eq!(later.unix_secs(), 1_000_005_400);