const std = @import("std"); const Allocator = std.mem.Allocator; const print = std.debug.print; const types = @import("./lib/types.zig"); const CommandStatus = types.CommandStatus; const CommandContext = types.CommandContext; pub const Time = struct { pub fn eval(time: Time, ctx: CommandContext) !CommandStatus { _ = time; const timestamp = std.time.timestamp(); const epoch_seconds = @as(u64, @intCast(timestamp)); const day_seconds = epoch_seconds % std.time.s_per_day; const hours = day_seconds / std.time.s_per_hour; const minutes = (day_seconds % std.time.s_per_hour) / std.time.s_per_min; const seconds = day_seconds % std.time.s_per_min; const output = try std.fmt.allocPrint(ctx.allocator, "Current time is {d:0>2}:{d:0>2}:{d:0>2}\n", .{ hours, minutes, seconds }); defer ctx.allocator.free(output); if (ctx.output_capture) |capture| { try capture.write(output); } else { print("{s}", .{output}); } return CommandStatus{ .Code = 0 }; } };