No description
- Zig 99.9%
- AMPL 0.1%
|
|
||
|---|---|---|
| .github/workflows | Add test | |
| src | Using expanded names for DST zones | |
| .gitignore |
chore(.gitignore): rename zig-cache/ to .zig-cache/
|
|
| build.zig | chore: remove redundant comment | |
| build.zig.zon | chore: update to latest zig | |
| LICENSE | Update license | |
| README.md | Add install section to the readme | |
| zig.mod | add zigmod support. | |
Zig Datetime
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
shiftTimezonemethod 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:
zig fetch --save git+https://github.com/frmdstryr/zig-datetime#master
- In your
build.zig, add thedatetimemodule 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