1
0
Fork
You've already forked zig-datetime
0
No description
  • Zig 99.9%
  • AMPL 0.1%
Find a file
2025年07月25日 16:21:23 -04:00
.github/workflows Add test 2023年02月22日 08:01:41 -05:00
src Using expanded names for DST zones 2025年04月16日 16:10:02 +03:00
.gitignore chore(.gitignore): rename zig-cache/ to .zig-cache/ 2025年03月05日 14:38:49 +00:00
build.zig chore: remove redundant comment 2025年07月19日 18:48:06 +02:00
build.zig.zon chore: update to latest zig 2025年03月04日 14:57:28 +00:00
LICENSE Update license 2019年12月19日 12:42:08 -05:00
README.md Add install section to the readme 2025年05月25日 11:52:56 +02:00
zig.mod add zigmod support. 2021年06月08日 09:47:20 +01:00

Zig Datetime

actions codecov

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

  1. Add zig-datetime as a dependency in your build.zig.zon:
zig fetch --save git+https://github.com/frmdstryr/zig-datetime#master
  1. 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: 2019年12月20日 22:03:02 UTC