harness: full-date timestamps on forwarded matrix messages (Pierre De Lancre)

This commit is contained in:
pierre committed 2026-10-02 02:53:22 +03:00
1 parent 9f7b573d01
commit ac4571e751
1 file changed
+8 -2
+8 -2
View File
@@ -561,13 +561,19 @@ pub fn main(init: std.process.Init) !void {
if (!std.mem.eql(u8, ev.sender, peer)) continue; if (!std.mem.eql(u8, ev.sender, peer)) continue;
if (ev.body.len == 0) continue; if (ev.body.len == 0) continue;
var ts_buf: [16]u8 = undefined; var ts_buf: [24]u8 = undefined;
const ts_str: []const u8 = blk: { const ts_str: []const u8 = blk: {
if (ev.ts <= 0) break :blk ""; if (ev.ts <= 0) break :blk "";
const secs: u64 = @intCast(@divTrunc(ev.ts, 1000)); const secs: u64 = @intCast(@divTrunc(ev.ts, 1000));
const epoch = std.time.epoch.EpochSeconds{ .secs = secs }; const epoch = std.time.epoch.EpochSeconds{ .secs = secs };
const day = epoch.getEpochDay();
const year_day = day.calculateYearDay();
const month_day = year_day.calculateMonthDay();
const sod = epoch.getDaySeconds(); const sod = epoch.getDaySeconds();
break :blk std.fmt.bufPrint(&ts_buf, " {d:0>2}:{d:0>2}Z", .{ sod.getHoursIntoDay(), sod.getMinutesIntoHour() }) catch ""; break :blk std.fmt.bufPrint(&ts_buf, " {d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2}Z", .{
year_day.year, month_day.month.numeric(), month_day.day_index + 1,
sod.getHoursIntoDay(), sod.getMinutesIntoHour(),
}) catch "";
}; };
// Attachment: download locally and forward the path to the agent. // Attachment: download locally and forward the path to the agent.