llkv_executor/utils/time.rs
1//! Time utility functions for the executor.
2
3use std::time::{SystemTime, UNIX_EPOCH};
4
5/// Returns the current time in microseconds since the Unix epoch.
6///
7/// This is commonly used for timestamp columns and time-based operations.
8/// Falls back to 0 if the system clock is before the Unix epoch (should never happen).
9pub fn current_time_micros() -> u64 {
10 SystemTime::now()
11 .duration_since(UNIX_EPOCH)
12 .unwrap_or_default()
13 .as_micros() as u64
14}