Skip to content

Commit 2c1e1bd

Browse files
authored
Rollup merge of #136301 - hkBst:patch-33, r=thomcc
Improve instant docs This should be enough to close #79881.
2 parents 2c380a4 + 9cb7432 commit 2c1e1bd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

library/std/src/time.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,17 @@ use crate::sys_common::{FromInner, IntoInner};
9393
/// use std::time::{Instant, Duration};
9494
///
9595
/// let now = Instant::now();
96-
/// let max_seconds = u64::MAX / 1_000_000_000;
97-
/// let duration = Duration::new(max_seconds, 0);
96+
/// let days_per_10_millennia = 365_2425;
97+
/// let solar_seconds_per_day = 60 * 60 * 24;
98+
/// let millenium_in_solar_seconds = 31_556_952_000;
99+
/// assert_eq!(millenium_in_solar_seconds, days_per_10_millennia * solar_seconds_per_day / 10);
100+
///
101+
/// let duration = Duration::new(millenium_in_solar_seconds, 0);
98102
/// println!("{:?}", now + duration);
99103
/// ```
100104
///
105+
/// For cross-platform code, you can comfortably use durations of up to around one hundred years.
106+
///
101107
/// # Underlying System calls
102108
///
103109
/// The following system calls are [currently] being used by `now()` to find out

0 commit comments

Comments
 (0)