#duration #numbers #num

num-time-duration

Provide a convenient way to create std::time::Duration from numbers

1 unstable release

0.1.0 Jul 12, 2021

#17 in #num

MIT license

6KB

num-time-duration

This crate provides a convenient way to create std::time::Duration from numbers.

Example:

use num_time_duration::NumTimeDuration;

let now = std::time::SystemTime::now();
assert_eq!(now + 1.hours(), now + std::time::Duration::from_secs(3600));
assert_eq!(now + 1.days(), now + std::time::Duration::from_secs(86400));
assert_eq!(now - 1.weeks(), now - std::time::Duration::from_secs(604800));

Usage

To use num-time-duration, add this to your Cargo.toml:

[dependencies]
num-time-duration = "0.1.0"

lib.rs:

This crate provides a convenient way to create std::time::Duration from numbers.

Example:

use num_time_duration::NumTimeDuration;

let now = std::time::SystemTime::now();
assert_eq!(now + 1.hours(), now + std::time::Duration::from_secs(3600));
assert_eq!(now + 1.days(), now + std::time::Duration::from_secs(86400));
assert_eq!(now - 1.weeks(), now - std::time::Duration::from_secs(604800));

Dependencies

~150KB