diff --git a/build.zig b/build.zig
index d6e855b..d1fc5a4 100644
--- a/build.zig
+++ b/build.zig
@@ -6,6 +6,12 @@ pub fn build(b: *std.Build) void {
const integration = b.option(bool, "integration", "Run integration tests") orelse false;
const provider = b.option([]const u8, "provider", "Test specific provider (github, gitlab, codeberg, sourcehut)");
+ // Add Zeit dependency
+ const zeit_dep = b.dependency("zeit", .{
+ .target = target,
+ .optimize = optimize,
+ });
+
const exe = b.addExecutable(.{
.name = "release-tracker",
.root_source_file = b.path("src/main.zig"),
@@ -13,6 +19,8 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
+ exe.root_module.addImport("zeit", zeit_dep.module("zeit"));
+
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
@@ -31,6 +39,8 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
+ unit_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
+
const run_unit_tests = b.addRunArtifact(unit_tests);
const test_step = b.step("test", "Run unit tests");
@@ -45,6 +55,8 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
+ integration_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
+
// Add filter for specific provider if specified
if (provider) |p| {
const filter = std.fmt.allocPrint(b.allocator, "{s} provider", .{p}) catch @panic("OOM");
@@ -68,6 +80,7 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
.filters = &[_][]const u8{"GitHub provider"},
});
+ github_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
const gitlab_tests = b.addTest(.{
.name = "gitlab-tests",
@@ -76,6 +89,7 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
.filters = &[_][]const u8{"GitLab provider"},
});
+ gitlab_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
const codeberg_tests = b.addTest(.{
.name = "codeberg-tests",
@@ -84,6 +98,7 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
.filters = &[_][]const u8{"Codeberg provider"},
});
+ codeberg_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
const sourcehut_tests = b.addTest(.{
.name = "sourcehut-tests",
@@ -92,6 +107,7 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
.filters = &[_][]const u8{"SourceHut provider"},
});
+ sourcehut_tests.root_module.addImport("zeit", zeit_dep.module("zeit"));
github_step.dependOn(&b.addRunArtifact(github_tests).step);
gitlab_step.dependOn(&b.addRunArtifact(gitlab_tests).step);
diff --git a/build.zig.zon b/build.zig.zon
new file mode 100644
index 0000000..08acdc3
--- /dev/null
+++ b/build.zig.zon
@@ -0,0 +1,18 @@
+.{
+ .name = .release_tracker,
+ .version = "0.1.0",
+ .fingerprint = 0x72165610c81e9c00,
+ .dependencies = .{
+ .zeit = .{
+ .url = "https://github.com/rockorager/zeit/archive/refs/tags/v0.6.0.tar.gz",
+ .hash = "zeit-0.0.0-5I6bk_pZAgB03N1p1GmVOZ--gOFwwQSRKj1UXb5tnaKS",
+ },
+ },
+ .paths = .{
+ "build.zig",
+ "build.zig.zon",
+ "src",
+ "README.md",
+ "LICENSE",
+ },
+}
diff --git a/src/atom.zig b/src/atom.zig
index 7fc6622..e44d552 100644
--- a/src/atom.zig
+++ b/src/atom.zig
@@ -1,6 +1,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
+const zeit = @import("zeit");
const Release = @import("main.zig").Release;
@@ -22,9 +23,11 @@ pub fn generateFeed(allocator: Allocator, releases: []const Release) ![]u8 {
\\
);
- // Add current timestamp in ISO 8601 format
- const timestamp = std.time.timestamp();
- try writer.print("{d}-01-01T00:00:00Z\n", .{1970 + @divTrunc(timestamp, 31536000)});
+ // Add current timestamp in proper ISO 8601 format using zeit
+ const now = zeit.instant(.{}) catch zeit.instant(.{ .source = .now }) catch unreachable;
+ const updated_str = try std.fmt.allocPrint(allocator, "{}", .{now});
+ defer allocator.free(updated_str);
+ try writer.print("{s}\n", .{updated_str});
// Add entries
for (releases) |release| {