From 828912bd979912570597241f2d9bed07af999d38 Mon Sep 17 00:00:00 2001 From: "Nurul Huda (Apon)" Date: Tue, 27 Jan 2026 01:44:29 +0600 Subject: [PATCH] chore: rm src/main.zig --- build.zig | 3 +-- example/src/main.zig | 55 +++++++++++++++++++++++++++++++++++------ src/main.zig | 58 -------------------------------------------- 3 files changed, 49 insertions(+), 67 deletions(-) delete mode 100644 src/main.zig diff --git a/build.zig b/build.zig index 62c2272..eb37e9c 100644 --- a/build.zig +++ b/build.zig @@ -91,7 +91,7 @@ pub fn build(b: *std.Build) !void { const exe = b.addExecutable(.{ .name = "temporalz", .root_module = b.createModule(.{ - .root_source_file = b.path("src/main.zig"), + .root_source_file = b.path("example/src/main.zig"), .target = target, .optimize = optimize, .imports = &.{ @@ -133,7 +133,6 @@ pub fn build(b: *std.Build) !void { .mode = .simple, }, }); - mod_tests.linkLibC(); test_step.dependOn(&b.addRunArtifact(mod_tests).step); const exe_tests = b.addTest(.{ .root_module = exe.root_module }); test_step.dependOn(&b.addRunArtifact(exe_tests).step); diff --git a/example/src/main.zig b/example/src/main.zig index a9365c1..75c6025 100644 --- a/example/src/main.zig +++ b/example/src/main.zig @@ -3,15 +3,56 @@ const Temporal = @import("temporalz"); pub fn main() !void { const allocator = std.heap.page_allocator; - const result = try Temporal.Instant.init(1_704_067_200_000_000_000); // 2024-01-01 00:00:00 UTC - defer result.deinit(); - std.debug.print("Instant.epoch_milliseconds: {}\n", .{result.epoch_milliseconds}); - std.debug.print("Instant.epoch_nanoseconds: {}\n", .{result.epoch_nanoseconds}); - const instant_str = try result.toString(allocator, .{}); - std.debug.print("Instant.toString(): {s}\n", .{instant_str}); + // --- Instant --- // + const instant = try Temporal.Instant.init(1_704_067_200_000_000_000); // 2024-01-01 00:00:00 UTC + defer instant.deinit(); + std.debug.print( + \\Instant + \\ + \\ - milliseconds: {} + \\ - nanoseconds: {} + \\ - toString(): {s} + \\ + \\ + , .{ + instant.epoch_milliseconds, + instant.epoch_nanoseconds, + try instant.toString(allocator, .{}), + }); + + // --- Duration --- // const dur = try Temporal.Duration.from("P1Y2M3DT4H5M6S"); - defer dur.deinit(); + + std.debug.print( + \\Duration + \\ + \\ - nanoseconds: {} + \\ - miliseconds: {} + \\ - seconds: {} + \\ - minutes: {} + \\ - hours: {} + \\ - days: {} + \\ - weeks: {} + \\ - months: {} + \\ - years: {} + \\ - toString(): {s} + \\ - total(): {{}} + \\ + \\ + , .{ + dur.nanoseconds(), + dur.milliseconds(), + dur.seconds(), + dur.minutes(), + dur.hours(), + dur.days(), + dur.weeks(), + dur.months(), + dur.years(), + try dur.toString(allocator, .{}), + // try dur.total(.{ .unit = .minute }), + }); } diff --git a/src/main.zig b/src/main.zig deleted file mode 100644 index 75c6025..0000000 --- a/src/main.zig +++ /dev/null @@ -1,58 +0,0 @@ -const std = @import("std"); -const Temporal = @import("temporalz"); - -pub fn main() !void { - const allocator = std.heap.page_allocator; - - // --- Instant --- // - const instant = try Temporal.Instant.init(1_704_067_200_000_000_000); // 2024-01-01 00:00:00 UTC - defer instant.deinit(); - - std.debug.print( - \\Instant - \\ - \\ - milliseconds: {} - \\ - nanoseconds: {} - \\ - toString(): {s} - \\ - \\ - , .{ - instant.epoch_milliseconds, - instant.epoch_nanoseconds, - try instant.toString(allocator, .{}), - }); - - // --- Duration --- // - const dur = try Temporal.Duration.from("P1Y2M3DT4H5M6S"); - defer dur.deinit(); - - std.debug.print( - \\Duration - \\ - \\ - nanoseconds: {} - \\ - miliseconds: {} - \\ - seconds: {} - \\ - minutes: {} - \\ - hours: {} - \\ - days: {} - \\ - weeks: {} - \\ - months: {} - \\ - years: {} - \\ - toString(): {s} - \\ - total(): {{}} - \\ - \\ - , .{ - dur.nanoseconds(), - dur.milliseconds(), - dur.seconds(), - dur.minutes(), - dur.hours(), - dur.days(), - dur.weeks(), - dur.months(), - dur.years(), - try dur.toString(allocator, .{}), - // try dur.total(.{ .unit = .minute }), - }); -}