authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-08-24 22:20:31 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-08-24 22:20:31 -07:00
log1e801b79c98f4275753f52313e9347b6a15c3373
tree41af040dd507bd01daf1b08630524a6e2b2c61a6
parent25165db8e626434ab6eae2cff64ba5e72e4fa062

add division constants


1 files changed, 30 insertions(+), 0 deletions(-)

time.zig+30
......@@ -494,3 +494,33 @@ fn wrap(val: u16, at: u16) u16 {
494494pub const Duration = struct {
495495 ms: u64,
496496};
497
498// Divisions of a nanosecond.
499pub const ns_per_us = 1000;
500pub const ns_per_ms = 1000 * ns_per_us;
501pub const ns_per_s = 1000 * ns_per_ms;
502pub const ns_per_min = 60 * ns_per_s;
503pub const ns_per_hour = 60 * ns_per_min;
504pub const ns_per_day = 24 * ns_per_hour;
505pub const ns_per_week = 7 * ns_per_day;
506
507// Divisions of a microsecond.
508pub const us_per_ms = 1000;
509pub const us_per_s = 1000 * us_per_ms;
510pub const us_per_min = 60 * us_per_s;
511pub const us_per_hour = 60 * us_per_min;
512pub const us_per_day = 24 * us_per_hour;
513pub const us_per_week = 7 * us_per_day;
514
515// Divisions of a millisecond.
516pub const ms_per_s = 1000;
517pub const ms_per_min = 60 * ms_per_s;
518pub const ms_per_hour = 60 * ms_per_min;
519pub const ms_per_day = 24 * ms_per_hour;
520pub const ms_per_week = 7 * ms_per_day;
521
522// Divisions of a second.
523pub const s_per_min = 60;
524pub const s_per_hour = s_per_min * 60;
525pub const s_per_day = s_per_hour * 24;
526pub const s_per_week = s_per_day * 7;