chore: rm src/main.zig
This commit is contained in:
parent
76c4ee4228
commit
828912bd97
3 changed files with 49 additions and 67 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 }),
|
||||
});
|
||||
}
|
||||
|
|
|
|||
58
src/main.zig
58
src/main.zig
|
|
@ -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 }),
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue