1.9 KiB
1.9 KiB
Temporalz
A Zig library for working with temporal types based on the Temporal Standard.
Temporalz provides Zig bindings to the Rust-based temporal_rs library for handling dates, times, and durations with proper timezone support.
Features
- Instant - Exact moment in time
- Duration - Length of time
- PlainDate - Date without time or timezone
- PlainTime - Time without date or timezone
- PlainDateTime - Date and time without timezone
- PlainYearMonth - Year and month
- PlainMonthDay - Month and day
- ZonedDateTime - Date, time, and timezone
Installation
Prerequisites
- Zig 0.15.2 or later
- Rust toolchain (only required if prebuilt binaries are not available for your platform)
Add as a Dependency
zig fetch --save=temporalz https://github.com/nurulhudaapon/temporalz/archive/refs/tags/v0.1.2.tar.gz
Use in build.zig
Add temporalz to your executable in build.zig:
const temporalz_dep = b.dependency("temporalz", .{ .target = target, .optimize = optimize });
const exe = b.addExecutable(.{
.name = "my_app",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "temporalz", .module = temporalz_dep.module("temporalz") },
},
}),
});
Supported Platforms
Prebuilt binaries are available for:
- aarch64-macos
- x86_64-macos
- aarch64-linux-gnu
- x86_64-linux-gnu
- x86_64-windows-gnu
- aarch64-windows-gnu
For unsupported platforms, the library will automatically build from source if the Rust toolchain is installed.
Development
Clone the Repository
git clone https://github.com/nurulhudaapon/temporalz.git
cd temporalz
Build and Run
zig build
zig build run
Run Tests
zig build test
License
MIT