SolarEnergy/central_backend/src/utils/time_utils.rs

18 lines
372 B
Rust
Raw Normal View History

use std::time::{SystemTime, UNIX_EPOCH};
/// Get the current time since epoch
2024-07-02 20:55:51 +00:00
pub fn time_secs() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
}
2024-07-02 20:55:51 +00:00
/// Get the current time since epoch
pub fn time_millis() -> u128 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_millis()
}