#chrono #duration #num #numbers

num-chrono-duration

Provide a convenient way to create chrono::Duration from numbers

1 unstable release

0.1.0 Jul 12, 2021

#539 in Date and time

MIT license

6KB

num-chrono-duration

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

Example:

use num_chrono_duration::NumChronoDuration;

let today = chrono::Utc::today();
assert_eq!(today + 1.hours(), today + chrono::Duration::hours(1));
assert_eq!(today + 1.days(), today + chrono::Duration::days(1));
assert_eq!(today - 1.weeks(), today - chrono::Duration::weeks(1));

Usage

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

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

lib.rs:

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

Example:

use num_chrono_duration::NumChronoDuration;

let today = chrono::Utc::today();
assert_eq!(today + 1.hours(), today + chrono::Duration::hours(1));
assert_eq!(today + 1.days(), today + chrono::Duration::days(1));
assert_eq!(today - 1.weeks(), today - chrono::Duration::weeks(1));

Dependencies

~1MB
~18K SLoC