mod: remove dependency to c std library and replace with ztime dependency for a pure zig implementation
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 57s

This commit is contained in:
2024-11-30 14:45:57 +01:00
parent 06752299be
commit df515b8cad
3 changed files with 17 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
const build_options = @import("build_options");
const c_time = if (build_options.timestamp) @cImport(@cInclude("time.h")) else null;
const ztime = if (build_options.timestamp) @import("ztime") else null;
const std = @import("std");
pub const std_options: std.Options = .{
@@ -55,12 +55,7 @@ fn log_writing(writer: anytype, comptime fmt: []const u8, args: anytype) void {
}
fn log_timestamp(writer: anytype) void {
const curtime = c_time.time(null);
const tm = c_time.localtime(&curtime);
var buffer: [16]u8 = undefined;
_ = c_time.strftime(@ptrCast(&buffer), 32, "%F %R", tm);
writer.print("[{s}] ", .{buffer}) catch return;
writer.print("[{any}] ", .{ztime.DateTime.now()}) catch return;
}
pub fn pretty_format(object: anytype, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {