pub const fn secs_to_clock(seconds: u32) -> (u8, u8, u8)
Expand description
Convert seconds to clock time, hours
, minutes
and seconds
.
This is the same as secs_to_hms
except it will wrap around,
e.g, 24:00:00
would turn into 00:00:00
.
- The seconds returned is guaranteed to be
0..=59
- The minutes returned is guaranteed to be
0..=59
- The hours returned is guaranteed to be
0..=23
// 59 seconds.
assert_eq!(secs_to_clock(59), (0, 0, 59));
// 1 minute.
assert_eq!(secs_to_clock(60), (0, 1, 0));
// 59 minutes, 59 seconds.
assert_eq!(secs_to_clock(3599), (0, 59, 59));
// 1 hour.
assert_eq!(secs_to_clock(3600), (1, 0, 0));
// 23 hours, 59 minutes, 59 seconds.
assert_eq!(secs_to_clock(86399), (23, 59, 59));
// 24 hours (wraps back)
assert_eq!(secs_to_clock(86400), (0, 0, 0));
// 24 hours, 59 minutes, 59 seconds (wraps back)
assert_eq!(secs_to_clock(89999), (0, 59, 59));