Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frmdstryr/zig-datetime
A date and time module for Zig
https://github.com/frmdstryr/zig-datetime
zig
Last synced: about 2 months ago
JSON representation
A date and time module for Zig
- Host: GitHub
- URL: https://github.com/frmdstryr/zig-datetime
- Owner: frmdstryr
- License: mit
- Created: 2019-12-19T17:15:38.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-05T17:07:17.000Z (9 months ago)
- Last Synced: 2024-05-02T02:55:54.071Z (7 months ago)
- Topics: zig
- Language: Zig
- Homepage:
- Size: 75.2 KB
- Stars: 69
- Watchers: 4
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - frmdstryr/zig-datetime
- awesome-zig - zig-datetime🗒️A date and time module for Zig
README
# Zig Datetime
[![actions](https://github.com/frmdstryr/zig-datetime/actions/workflows/ci.yml/badge.svg)](https://github.com/frmdstryr/zig-datetime/actions)
[![codecov](https://codecov.io/gh/frmdstryr/zig-datetime/branch/master/graph/badge.svg)](https://codecov.io/gh/frmdstryr/zig-datetime)A datetime module for Zig with an api similar to python's Arrow.
> NOTE: This does not implement DST.
```zig
const allocator = std.heap.page_allocator;
const date = try Date.create(2019, 12, 25);
const next_year = date.shiftDays(7);
assert(next_year.year == 2020);
assert(next_year.month == 1);
assert(next_year.day == 1);// In UTC
const now = Datetime.now();
const now_str = try now.formatHttp(allocator);
defer allocator.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```