From 5c1fd21a84d17dcf765e297703751c924cadfe2a Mon Sep 17 00:00:00 2001 From: Jeeves Date: Fri, 15 Mar 2024 20:42:20 -0600 Subject: [PATCH] uptime: fix math --- src/modules/uptime.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/uptime.zig b/src/modules/uptime.zig index 70260af..351cfef 100644 --- a/src/modules/uptime.zig +++ b/src/modules/uptime.zig @@ -23,13 +23,13 @@ pub fn getJson(module: *const Module) !Module.JSON { var uptime_split = std.mem.splitScalar(u8, uptime_string[0 .. uptime_string.len - 1], ' '); var uptime = try std.fmt.parseFloat(f32, uptime_split.first()); - const days = uptime / std.time.s_per_day; - uptime -= std.time.s_per_day * @floor(days); - const hours = uptime / std.time.s_per_hour; - uptime -= std.time.s_per_hour * @floor(hours); - const mins = uptime / std.time.s_per_min; + uptime /= 60; + const mins = @mod(uptime, 60); + uptime /= 60; + const hours = @mod(uptime, 24); + uptime /= 24; return .{ - .full_text = try std.fmt.allocPrint(self.module.allocator, "{d:0>1.0}d {d:0>1.0}h {d:.0}m", .{ days, hours, mins }), + .full_text = try std.fmt.allocPrint(self.module.allocator, "{d:0>1.0}d {d:0>1.0}h {d:.0}m", .{ uptime, hours, mins }), }; }