Function cuprate_helper::time::unix_clock

source ยท
pub const fn unix_clock(seconds_after_unix_epoch: u64) -> u32
Expand description

Get the clock time of a UNIX timestamp

The input must be a UNIX timestamp.

The returned u64 will represent how many seconds has passed on the day corresponding to that timestamp.

The output is guaranteed to be in the range of 0..=86399.

// October 20th 2023 - 10:18:30 PM
const TIME: u64 = 1697840310;

let seconds = unix_clock(TIME);
assert_eq!(seconds, 80310);

let (h, m, s) = secs_to_clock(seconds);
// 10:18:30 PM.
assert_eq!((h, m, s), (22, 18, 30))