aboutsummaryrefslogtreecommitdiff
path: root/ctr-std/src/time.rs
diff options
context:
space:
mode:
authorFenrir <[email protected]>2018-04-14 20:02:05 -0600
committerFenrir <[email protected]>2018-04-21 16:35:01 -0600
commitb330206f5590d88a2f995321d2ea847ded951d1d (patch)
tree4fecd0ca00b754c494e96b13e9837db48de93109 /ctr-std/src/time.rs
parentMove more implementation details to `imp` module (diff)
downloadctru-rs-b330206f5590d88a2f995321d2ea847ded951d1d.tar.xz
ctru-rs-b330206f5590d88a2f995321d2ea847ded951d1d.zip
Update for Rust nightly 2018-04-19
Diffstat (limited to 'ctr-std/src/time.rs')
-rw-r--r--ctr-std/src/time.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/ctr-std/src/time.rs b/ctr-std/src/time.rs
index 12f2a9b..1215302 100644
--- a/ctr-std/src/time.rs
+++ b/ctr-std/src/time.rs
@@ -49,6 +49,9 @@ pub use core::time::Duration;
/// allows measuring the duration between two instants (or comparing two
/// instants).
///
+/// The size of an `Instant` struct may vary depending on the target operating
+/// system.
+///
/// Example:
///
/// ```no_run
@@ -88,6 +91,9 @@ pub struct Instant(time::Instant);
/// fixed point in time, a `SystemTime` can be converted to a human-readable time,
/// or perhaps some other string representation.
///
+/// The size of a `SystemTime` struct may vary depending on the target operating
+/// system.
+///
/// [`Instant`]: ../../std/time/struct.Instant.html
/// [`Result`]: ../../std/result/enum.Result.html
/// [`Duration`]: ../../std/time/struct.Duration.html
@@ -253,6 +259,29 @@ 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.
+ ///
+ /// 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
+ /// `SystemTime` instance can tell how far away from this point in time a
+ /// measurement lies, and using `UNIX_EPOCH + duration` can be used to create a
+ /// `SystemTime` instance to represent another fixed point in time.
+ ///
+ /// # Examples
+ ///
+ /// ```no_run
+ /// #![feature(assoc_unix_epoch)]
+ /// use std::time::SystemTime;
+ ///
+ /// match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
+ /// Ok(n) => println!("1970-01-01 00:00:00 UTC was {} seconds ago!", n.as_secs()),
+ /// Err(_) => panic!("SystemTime before UNIX EPOCH!"),
+ /// }
+ /// ```
+ #[unstable(feature = "assoc_unix_epoch", issue = "49502")]
+ pub const UNIX_EPOCH: SystemTime = UNIX_EPOCH;
+
/// Returns the system time corresponding to "now".
///
/// # Examples