diff options
| author | Marijn Schouten <hkBst@users.noreply.github.com> | 2025-01-30 15:03:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-30 15:03:50 +0100 |
| commit | 9cb74323aa9e17d910166994b824a9797f77d7a3 (patch) | |
| tree | 225082330ee5ddab75e19d8bb6aabf557b8d63c8 | |
| parent | e6f12c8b7d8d5c821c32fb2739ea01d1d874c58a (diff) | |
| download | rust-9cb74323aa9e17d910166994b824a9797f77d7a3.tar.gz rust-9cb74323aa9e17d910166994b824a9797f77d7a3.zip | |
Improve instant docs
| -rw-r--r-- | library/std/src/time.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 9f4f8a0d088..797c5ff24c0 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -96,11 +96,17 @@ use crate::sys_common::{FromInner, IntoInner}; /// use std::time::{Instant, Duration}; /// /// let now = Instant::now(); -/// let max_seconds = u64::MAX / 1_000_000_000; -/// let duration = Duration::new(max_seconds, 0); +/// let days_per_10_millennia = 365_2425; +/// let solar_seconds_per_day = 60 * 60 * 24; +/// let millenium_in_solar_seconds = 31_556_952_000; +/// assert_eq!(millenium_in_solar_seconds, days_per_10_millennia * solar_seconds_per_day / 10); +/// +/// let duration = Duration::new(millenium_in_solar_seconds, 0); /// println!("{:?}", now + duration); /// ``` /// +/// For cross-platform code, you can comfortably use durations of up to around one hundred years. +/// /// # Underlying System calls /// /// The following system calls are [currently] being used by `now()` to find out |
