refactor(macos-uptime): use new Io Timestamp

This commit is contained in:
utox39
2026-02-11 18:51:10 +01:00
parent 525156f4c6
commit 6c70dac17c

View File

@@ -35,7 +35,7 @@ pub fn getLocale(allocator: std.mem.Allocator, environ: std.process.Environ) ![]
/// Returns the system uptime.
///
/// Uses `sysctl` to fetch the system boot time and calculates the elapsed time.
pub fn getSystemUptime() !SystemUptime {
pub fn getSystemUptime(io: std.Io) !SystemUptime {
const seconds_per_day: f64 = 86400.0;
const hours_per_day: f64 = 24.0;
const seconds_per_hour: f64 = 3600.0;
@@ -49,7 +49,7 @@ pub fn getSystemUptime() !SystemUptime {
var name = [_]c_int{ c_sysctl.CTL_KERN, c_sysctl.KERN_BOOTTIME };
if (c_sysctl.sysctl(&name, name.len, &boot_time, &size, null, 0) == 0) {
const boot_seconds = @as(f64, @floatFromInt(boot_time.tv_sec));
const now_seconds = @as(f64, @floatFromInt(std.time.timestamp()));
const now_seconds = @as(f64, @floatFromInt(std.Io.Timestamp.now(io, .real).toSeconds()));
uptime_seconds = now_seconds - boot_seconds;
} else {
return error.UnableToGetSystemUptime;