fix: main() usage of instant

This commit is contained in:
Nurul Huda (Apon) 2026-01-24 01:06:26 +06:00
parent 834d5b7f13
commit 518998fcd8

View file

@ -2,14 +2,17 @@ const std = @import("std");
const Temporal = @import("temporalz"); const Temporal = @import("temporalz");
pub fn main() !void { pub fn main() !void {
const result = try Temporal.Instant.init(1704067200000); // 2024-01-01 00:00:00 UTC 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(); defer result.deinit();
std.debug.print("Instant with Epoch: {}ms\n", .{result.epoch}); 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});
const cloned = result.clone(); const dur = try Temporal.Duration.from("P1Y2M3DT4H5M6S");
std.debug.print("Is Instant Equal: {}\n", .{cloned.equals(result)}); defer dur.deinit();
// const dur_str = try dur.toString(allocator, .{});
const instant_str = try cloned.toString(std.heap.page_allocator, .{}); // std.debug.print("Duration String: {s}\n", .{dur_str});
std.debug.print("Cloned Instant String: {s}\n", .{instant_str});
} }