Skip to content

Commit 8d35518

Browse files
committed
fix: logging date should match actual date
1 parent 7637b1a commit 8d35518

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/logging.zig

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn init2(gpa: std.mem.Allocator, path: ?[]const u8, level: std.log.Level) !void
4747
var bw = std.io.bufferedWriter(logfile.writer());
4848
bw.writer().print(
4949
\\
50-
\\-----seamstress startup time: {}-----
50+
\\-----seamstress startup time: {}-----
5151
\\
5252
, .{date}) catch {};
5353
bw.flush() catch {};
@@ -73,14 +73,14 @@ const Date = struct {
7373
.seconds = into_day.getSecondsIntoMinute(),
7474
.minute = into_day.getMinutesIntoHour(),
7575
.hour = into_day.getHoursIntoDay(),
76-
.day = month.day_index,
76+
.day = month.day_index + 1,
7777
.month = month.month.numeric(),
7878
.year = year.year,
7979
};
8080
}
8181

8282
pub fn format(date: Date, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
83-
try writer.print("{[year]d:0>4}-{[month]d:0>2}-{[day]d:0>2} {[hour]d:0>2}:{[minute]d:0>2}:{[seconds]d:0>2}", date);
83+
try writer.print("{[year]d:0>4}-{[month]d:0>2}-{[day]d:0>2} UTC {[hour]d:0>2}:{[minute]d:0>2}:{[seconds]d:0>2}", date);
8484
}
8585

8686
test format {
@@ -92,9 +92,9 @@ const Date = struct {
9292
.minute = 27,
9393
.seconds = 5,
9494
};
95-
var buf: [4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2]u8 = undefined;
95+
var buf: [4 + 1 + 2 + 1 + 2 + 1 + 3 + 1 + 2 + 1 + 2 + 1 + 2]u8 = undefined;
9696
const str = try std.fmt.bufPrint(&buf, "{}", .{date});
97-
try std.testing.expectEqualStrings("2025-01-04 10:27:05", str);
97+
try std.testing.expectEqualStrings("2025-01-04 UTC 10:27:05", str);
9898
}
9999
};
100100

@@ -130,3 +130,7 @@ pub const known_folders_config: folders.KnownFolderConfig = .{
130130
const std = @import("std");
131131
const builtin = @import("builtin");
132132
const folders = @import("known-folders");
133+
134+
test "ref" {
135+
_ = Date;
136+
}

src/main.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ const Env = @import("env.zig");
100100

101101
test "ref" {
102102
_ = Seamstress;
103+
_ = logging;
103104
}

0 commit comments

Comments
 (0)