chore: rm src/main.zig

This commit is contained in:
Nurul Huda (Apon) 2026-01-27 01:44:29 +06:00
parent 76c4ee4228
commit 828912bd97
No known key found for this signature in database
GPG key ID: 5D3F1DE2855A2F79
3 changed files with 49 additions and 67 deletions

View file

@ -91,7 +91,7 @@ pub fn build(b: *std.Build) !void {
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = "temporalz", .name = "temporalz",
.root_module = b.createModule(.{ .root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"), .root_source_file = b.path("example/src/main.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.imports = &.{ .imports = &.{
@ -133,7 +133,6 @@ pub fn build(b: *std.Build) !void {
.mode = .simple, .mode = .simple,
}, },
}); });
mod_tests.linkLibC();
test_step.dependOn(&b.addRunArtifact(mod_tests).step); test_step.dependOn(&b.addRunArtifact(mod_tests).step);
const exe_tests = b.addTest(.{ .root_module = exe.root_module }); const exe_tests = b.addTest(.{ .root_module = exe.root_module });
test_step.dependOn(&b.addRunArtifact(exe_tests).step); test_step.dependOn(&b.addRunArtifact(exe_tests).step);

View file

@ -3,15 +3,56 @@ const Temporal = @import("temporalz");
pub fn main() !void { pub fn main() !void {
const allocator = std.heap.page_allocator; 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}); // --- Instant --- //
std.debug.print("Instant.epoch_nanoseconds: {}\n", .{result.epoch_nanoseconds}); const instant = try Temporal.Instant.init(1_704_067_200_000_000_000); // 2024-01-01 00:00:00 UTC
const instant_str = try result.toString(allocator, .{}); defer instant.deinit();
std.debug.print("Instant.toString(): {s}\n", .{instant_str});
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"); const dur = try Temporal.Duration.from("P1Y2M3DT4H5M6S");
defer dur.deinit(); 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 }),
});
} }

View file

@ -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 }),
});
}