Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bcrist/tempora
Simple Zig Dates/Times/Timezones
https://github.com/bcrist/tempora
calendar date datetime time tz tzdata tzinfo zig zig-library zig-package ziglang
Last synced: 21 days ago
JSON representation
Simple Zig Dates/Times/Timezones
- Host: GitHub
- URL: https://github.com/bcrist/tempora
- Owner: bcrist
- License: mit
- Created: 2024-03-09T02:04:51.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-07-06T16:21:43.000Z (6 months ago)
- Last Synced: 2024-07-07T16:04:40.464Z (6 months ago)
- Topics: calendar, date, datetime, time, tz, tzdata, tzinfo, zig, zig-library, zig-package, ziglang
- Language: Zig
- Homepage:
- Size: 349 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Tempora
### Simple Zig Dates/Times/Timezones## Features
* Efficient storage (32b `Time`, 32b `Date`, 64b `Date_Time`)
* Composition and decomposition (year, ordinal day/week, month, day, weekday, hour, minute, second, ms)
* Add/subtract days/hours/minutes/seconds/ms
* Advance to the next weekday/day/ordinal day
* Convert to/from unix timestamps
* Embedded IANA timezone database and modified version of [zig-tzif](https://github.com/leroycep/zig-tzif) (adds about 200k to binary size when used)
* Query current timezone on both unix and Windows systems
* Moment.js style formatting and parsing (through `std.fmt`)## Limitations
* It's not possible to store most "out of bounds" dates/times (e.g. Jan 32).
* Localized month and weekday names are not supported; only English.
* Non-Gregorian calendars are not supported.
* Date/time values directly correspond to timestamps, so accurate durations that take leap seconds into account are not possible (but leap seconds are being abolished in 2035 anyway).
* I am certain that there are more optimized algorithms for timestamp <--> calendar conversions (but performance should be fine for all but the most demanding use cases).