Skip to content

Commit

Permalink
Rollup merge of rust-lang#44315 - kallisti5:epoch-doc-example-squashe…
Browse files Browse the repository at this point in the history
…d, r=GuillaumeGomez

std/time: Give an example to get UNIX_EPOCH in seconds
  • Loading branch information
Mark-Simulacrum authored Sep 6, 2017
2 parents 3602c6f + 1c5bf24 commit dc5c94d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libstd/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,17 @@ impl fmt::Debug for SystemTime {
/// [`SystemTime`] instance to represent another fixed point in time.
///
/// [`SystemTime`]: ../../std/time/struct.SystemTime.html
///
/// # Examples
///
/// ```no_run
/// use std::time::{SystemTime, UNIX_EPOCH};
///
/// match SystemTime::now().duration_since(UNIX_EPOCH) {
/// Ok(n) => println!("1970-01-01 00:00:00 UTC was {} seconds ago!", n.as_secs()),
/// Err(_) => panic!("SystemTime before UNIX EPOCH!"),
/// }
/// ```
#[stable(feature = "time2", since = "1.8.0")]
pub const UNIX_EPOCH: SystemTime = SystemTime(time::UNIX_EPOCH);

Expand Down

0 comments on commit dc5c94d

Please sign in to comment.