Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,14 @@ Or install another [tag](https://github.com/rockorager/zeit/tags) instead of mai
const std = @import("std");
const zeit = @import("zeit");

pub fn main() !void {
const allocator = std.heap.page_allocator;
var threaded = std.Io.Threaded.init(allocator, .{});
defer threaded.deinit();
const io = threaded.io();
pub fn main(init: std.process.Init) !void {

// Get a "now" instant in UTC.
const now = zeit.instant(.{.now = io}, &zeit.utc);
const now = zeit.instant(.{ .now = init.io }, &zeit.utc);

// Load our local timezone. This needs an allocator. Optionally pass in a
// zeit.EnvConfig to support TZ and TZDIR environment variables
const local = try zeit.local(allocator, io, .{});
const local = try zeit.local(init.gpa, init.io, .{});
defer local.deinit();

// Convert our instant to a new timezone
Expand All @@ -47,7 +43,7 @@ pub fn main() !void {
const dt = now_local.time();

// Print it out
std.debug.print("{}", .{dt});
std.debug.print("{}\n", .{dt});

// zeit.Time{
// .year = 2024,
Expand Down Expand Up @@ -78,20 +74,20 @@ pub fn main() !void {
// Load an arbitrary location using IANA location syntax. The location name
// comes from an enum which will automatically map IANA location names to
// Windows names, as needed. Pass an optional EnvConfig to support TZDIR
const vienna = try zeit.loadTimeZone(allocator, io, .@"Europe/Vienna", .{});
const vienna = try zeit.loadTimeZone(init.gpa, init.io, .@"Europe/Vienna", .{});
defer vienna.deinit();

// Parse an Instant from an ISO8601 or RFC3339 string
_ = try zeit.instantFromText(
.iso8601,
"2024-03-16T08:38:29.496-1200",
&zeit.utc,
});
);

_ = try zeit.instantFromText(
.rfc3339,
"2024-03-16T08:38:29.496706064-1200",
&zeit.utc,
});
);
}
```
Loading
Loading