Skip to content

Commit cea1bed

Browse files
authored
Improve instant docs
1 parent 24ff8ae commit cea1bed

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: std/src/time.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,17 @@ use crate::sys_common::{FromInner, IntoInner};
9696
/// use std::time::{Instant, Duration};
9797
///
9898
/// let now = Instant::now();
99-
/// let max_seconds = u64::MAX / 1_000_000_000;
100-
/// let duration = Duration::new(max_seconds, 0);
99+
/// let days_per_10_millennia = 365_2425;
100+
/// let solar_seconds_per_day = 60 * 60 * 24;
101+
/// let millenium_in_solar_seconds = 31_556_952_000;
102+
/// assert_eq!(millenium_in_solar_seconds, days_per_10_millennia * solar_seconds_per_day / 10);
103+
///
104+
/// let duration = Duration::new(millenium_in_solar_seconds, 0);
101105
/// println!("{:?}", now + duration);
102106
/// ```
103107
///
108+
/// For cross-platform code, you can comfortably use durations of up to around one hundred years.
109+
///
104110
/// # Underlying System calls
105111
///
106112
/// The following system calls are [currently] being used by `now()` to find out

0 commit comments

Comments
 (0)