Something went wrong. Try again.
A basic datetime module in zig
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546const std = @import("std");
pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{});
const datetime = b.addModule("datetime", .{ .root_source_file = b.path("src/datetime.zig"), .target = target, .optimize = optimize, }); const zoneinfo = b.addModule("zoneinfo", .{ .root_source_file = b.path("src/zoneinfo.zig"), .target = target, .optimize = optimize, });
const exe = b.addExecutable(.{ .name = "date", .root_module = b.createModule(.{ .root_source_file = b.path("src/date.zig"), .target = target, .optimize = optimize, }), }); exe.root_module.addImport("datetime", datetime); exe.root_module.addImport("zoneinfo", zoneinfo);
b.installArtifact(exe);
const test_step = b.step("test", "Run unit tests"); const tests = [_][]const u8{ "src/datetime.zig", "src/zoneinfo.zig" };
for (tests) |root| { const exe_unit_tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path(root), .target = target, .optimize = optimize, }), }); const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); test_step.dependOn(&run_exe_unit_tests.step); }}