summaryrefslogtreecommitdiffstats
path: root/library/std/src/time.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/time.rs')
-rw-r--r--library/std/src/time.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/library/std/src/time.rs b/library/std/src/time.rs
index 00e2857a1..005d8c767 100644
--- a/library/std/src/time.rs
+++ b/library/std/src/time.rs
@@ -58,6 +58,8 @@ pub use core::time::TryFromFloatSecsError;
/// some seconds may be longer than others). An instant may jump forwards or
/// experience time dilation (slow down or speed up), but it will never go
/// backwards.
+/// As part of this non-guarantee it is also not specified whether system suspends count as
+/// elapsed time or not. The behavior varies across platforms and rust versions.
///
/// Instants are opaque types that can only be compared to one another. There is
/// no method to get "the number of seconds" from an instant. Instead, it only
@@ -176,6 +178,14 @@ pub struct Instant(time::Instant);
/// The size of a `SystemTime` struct may vary depending on the target operating
/// system.
///
+/// A `SystemTime` does not count leap seconds.
+/// `SystemTime::now()`'s behaviour around a leap second
+/// is the same as the operating system's wall clock.
+/// The precise behaviour near a leap second
+/// (e.g. whether the clock appears to run slow or fast, or stop, or jump)
+/// depends on platform and configuration,
+/// so should not be relied on.
+///
/// Example:
///
/// ```no_run
@@ -461,6 +471,9 @@ impl fmt::Debug for Instant {
impl SystemTime {
/// An anchor in time which can be used to create new `SystemTime` instances or
/// learn about where in time a `SystemTime` lies.
+ //
+ // NOTE! this documentation is duplicated, here and in std::time::UNIX_EPOCH.
+ // The two copies are not quite identical, because of the difference in naming.
///
/// This constant is defined to be "1970-01-01 00:00:00 UTC" on all systems with
/// respect to the system clock. Using `duration_since` on an existing
@@ -468,6 +481,11 @@ impl SystemTime {
/// measurement lies, and using `UNIX_EPOCH + duration` can be used to create a
/// `SystemTime` instance to represent another fixed point in time.
///
+ /// `duration_since(UNIX_EPOCH).unwrap().as_secs()` returns
+ /// the number of non-leap seconds since the start of 1970 UTC.
+ /// This is a POSIX `time_t` (as a `u64`),
+ /// and is the same time representation as used in many Internet protocols.
+ ///
/// # Examples
///
/// ```no_run
@@ -617,6 +635,9 @@ impl fmt::Debug for SystemTime {
/// An anchor in time which can be used to create new `SystemTime` instances or
/// learn about where in time a `SystemTime` lies.
+//
+// NOTE! this documentation is duplicated, here and in SystemTime::UNIX_EPOCH.
+// The two copies are not quite identical, because of the difference in naming.
///
/// This constant is defined to be "1970-01-01 00:00:00 UTC" on all systems with
/// respect to the system clock. Using `duration_since` on an existing
@@ -624,6 +645,11 @@ impl fmt::Debug for SystemTime {
/// measurement lies, and using `UNIX_EPOCH + duration` can be used to create a
/// [`SystemTime`] instance to represent another fixed point in time.
///
+/// `duration_since(UNIX_EPOCH).unwrap().as_secs()` returns
+/// the number of non-leap seconds since the start of 1970 UTC.
+/// This is a POSIX `time_t` (as a `u64`),
+/// and is the same time representation as used in many Internet protocols.
+///
/// # Examples
///
/// ```no_run