You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A datetime module for Zig with an api similar to python's Arrow.
Note
DST is now implemeted to the library. Some timezones that relying on islamic calendar for DST might not work yet. It is also possible that we might have skipped some timezones by mistake because there are a lot of timezones.
Important
With DST implementation, the shiftTimezone method changed and now taking timezone argument passed by value contrary to before that it was passed by pointer.
Install
Add zig-datetime as a dependency in your build.zig.zon:
In your build.zig, add the datetime module as a dependency you your program:
constpg=b.dependency("datetime", .{
.target=target,
.optimize=optimize,
});
// the executable from your call to exe_mod.addExecutableexe.root_module.addImport("datetime", pg.module("datetime"));
Example
constallocator=std.heap.page_allocator;
constdate=tryDate.create(2019, 12, 25);
constnext_year=date.shiftDays(7);
assert(next_year.year==2020);
assert(next_year.month==1);
assert(next_year.day==1);
// In UTCconstnow=Datetime.now();
constnow_str=trynow.formatHttp(allocator);
deferallocator.free(now_str);
std.debug.warn("The time is now: {}\n", .{now_str});
// The time is now: Fri, 20 Dec 2019 22:03:02 UTC