diem_infallible/
time.rs

1// Copyright (c) The Diem Core Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4// Copyright 2021 Conflux Foundation. All rights reserved.
5// Conflux is free software and distributed under GNU General Public License.
6// See http://www.gnu.org/licenses/
7
8#![forbid(unsafe_code)]
9
10use std::time::{Duration, SystemTime};
11
12/// Gives the duration since the Unix epoch, notice the expect.
13pub fn duration_since_epoch() -> Duration {
14    SystemTime::now()
15        .duration_since(SystemTime::UNIX_EPOCH)
16        .expect("System time is before the UNIX_EPOCH")
17}