Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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).