1use std::time::{Duration, SystemTime, UNIX_EPOCH};
2
3use time::UtcOffset;
4
5#[cfg(feature = "local-offset")]
6pub use local_time::{local_now, local_utc_offset};
7
8pub mod human_duration;
9#[cfg(feature = "local-offset")]
10mod local_time;
11
12pub const THAILAND_UTC_OFFSET: UtcOffset = {
14 match UtcOffset::from_hms(7, 0, 0) {
15 Ok(val) => val,
16 Err(_) => unreachable!(),
17 }
18};
19
20pub fn duration_since_unix_time(unix_timestamp: u64) -> Option<Duration> {
21 let now_epoch = SystemTime::now().duration_since(UNIX_EPOCH).ok()?;
22 now_epoch.checked_sub(Duration::from_secs(unix_timestamp))
23}