{"id":16985646,"url":"https://github.com/fobersteiner/zdt","last_synced_at":"2025-03-20T08:20:08.987Z","repository":{"id":240495064,"uuid":"795874688","full_name":"FObersteiner/zdt","owner":"FObersteiner","description":"Timezoned Datetime in Zig","archived":false,"fork":false,"pushed_at":"2025-02-14T19:35:40.000Z","size":10863,"stargazers_count":16,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-19T13:21:39.698Z","etag":null,"topics":["date","datetime","duration","time","timezones","zig","zig-package","ziglang"],"latest_commit_sha":null,"homepage":"https://fobersteiner.github.io/zdt/","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FObersteiner.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-04T10:06:10.000Z","updated_at":"2025-02-15T21:15:46.000Z","dependencies_parsed_at":"2024-05-19T10:27:20.882Z","dependency_job_id":"1dc5dd68-a7db-4970-b517-a1ff1181113a","html_url":"https://github.com/FObersteiner/zdt","commit_stats":null,"previous_names":["fobersteiner/zdt"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FObersteiner%2Fzdt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FObersteiner%2Fzdt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FObersteiner%2Fzdt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FObersteiner%2Fzdt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FObersteiner","download_url":"https://codeload.github.com/FObersteiner/zdt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244574847,"owners_count":20474823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["date","datetime","duration","time","timezones","zig","zig-package","ziglang"],"created_at":"2024-10-14T02:43:54.914Z","updated_at":"2025-03-20T08:20:08.981Z","avatar_url":"https://github.com/FObersteiner.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- -*- coding: utf-8 -*- --\u003e\n\n[![Zig](https://img.shields.io/badge/-Zig-F7A41D?style=flat\u0026logo=zig\u0026logoColor=white)](https://ziglang.org/) ⚡ [![tests](https://github.com/FObersteiner/zdt/actions/workflows/zdt-tests.yml/badge.svg)](https://github.com/FObersteiner/zdt/actions/workflows/zdt-tests.yml)  [![GitHub Release](https://img.shields.io/github/v/release/FObersteiner/zdt)](https://github.com/FObersteiner/zdt/releases)  [![tzdata](https://img.shields.io/badge/tzdata-2025a-blue)](https://www.iana.org/time-zones)  [![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](https://github.com/FObersteiner/zdt/blob/master/LICENSE)\n\n# zdt\n\n**Time\u003cins\u003ez\u003c/ins\u003eoned \u003cins\u003eD\u003c/ins\u003eate\u003cins\u003et\u003c/ins\u003eime in Zig.** Opinionated, and mostly for learning purposes.\n\n- [API overview](https://github.com/FObersteiner/zdt/wiki/API-overview)\n- [Examples](https://github.com/FObersteiner/zdt/tree/master/examples)\n- [Roadmap](https://github.com/FObersteiner/zdt/wiki/Roadmap)\n\n### [Demo](https://github.com/FObersteiner/zdt/blob/master/examples/demo.zig)\n\n```zig\n// need an allocator for the time zones since the size of the rule-files varies.\nvar gpa = std.heap.GeneralPurposeAllocator(.{}){};\ndefer _ = gpa.deinit();\nconst allocator = gpa.allocator();\n\n// zdt embeds the IANA tz database:\nvar tz_LA = try zdt.Timezone.fromTzdata(\"America/Los_Angeles\", allocator);\ndefer tz_LA.deinit();\n\n// you can also use your system's tz data at runtime;\n// this will very likely not work on Windows, so we use the embedded version here as well.\nvar tz_Paris = switch (builtin.os.tag) {\n    .windows =\u003e try zdt.Timezone.fromTzdata(\"Europe/Paris\", allocator),\n    else =\u003e try zdt.Timezone.fromSystemTzdata(\"Europe/Paris\", zdt.Timezone.tzdb_prefix, allocator),\n};\ndefer tz_Paris.deinit();\n\n// ISO8601 parser on-board, accepts wide variety of compatible formats\nconst a_datetime = try zdt.Datetime.fromISO8601(\"2022-03-07\");\nconst this_time_LA = try a_datetime.tzLocalize(.{ .tz = \u0026tz_LA });\n\n// string output also requires allocation...\nvar buf = std.ArrayList(u8).init(allocator);\ndefer buf.deinit();\ntry this_time_LA.toString(\"%I %p, %Z\", buf.writer());\n\nconst this_time_Paris = try this_time_LA.tzConvert(.{ .tz = \u0026tz_Paris });\n\n// '{s}' directive gives ISO8601 format by default;\nstd.debug.print(\n    \"Time, LA : {s} ({s})\\n... that's {s} in Paris ({s})\\n\\n\",\n    .{ this_time_LA, buf.items, this_time_Paris, this_time_Paris.tzAbbreviation() },\n);\n// Time, LA : 2022-03-07T00:00:00-08:00 (12 am, PST)\n// ... that's 2022-03-07T09:00:00+01:00 in Paris\n\nconst wall_diff = try this_time_Paris.diffWall(this_time_LA);\nconst abs_diff = this_time_Paris.diff(this_time_LA);\n\nstd.debug.print(\"Wall clock time difference: {s}\\nAbsolute time difference: {s}\\n\\n\", .{ wall_diff, abs_diff });\n// Wall clock time difference: PT9H\n// Absolute time difference: PT0S\n\n// Easteregg:\nconst now = zdt.Datetime.nowUTC();\nconst easter_date = try zdt.Datetime.EasterDate(now.year);\nbuf.clearAndFree();\ntry easter_date.toString(\"%B %d, %Y\", buf.writer());\nstd.debug.print(\"Easter this year is on {s}\\n\", .{buf.items});\n// Easter this year is on April 20, 2025\n```\n\n## Documentation\n\nSee [Wiki](https://github.com/FObersteiner/zdt/wiki)\n\n## Credits\n\n- inspiration for early version of parser, and most of the POSIX TZ code: [leroycep/zig-tzif](https://github.com/leroycep/zig-tzif)\n- date \u003c--\u003e days since Unix epoch conversion, algorithm: [cassioneri/eaf](https://github.com/cassioneri/eaf) . Zig implementation: [travisstaloch/date-zig](https://github.com/travisstaloch/date-zig)\n- general support from \u003chttps://ziggit.dev/\u003e\n\n## Development\n\nSee [changelog](https://github.com/FObersteiner/zdt/blob/master/CHANGELOG.md)\n\n## Zig version\n\n- zdt v0.6.x: Zig 0.14\n- zdt v0.5.x: Zig 0.13 / 0.14\n- zdt v0.4.x: Zig 0.13\n\nThis library is developed with Zig 'master' - this might sometimes introduce version incompatibilities. If you just want to use the library, use a tagged version that suites your Zig version.\n\n## IANA timezone database version\n\n- `v0.4.5+`: `2025a` (current)\n- `v0.2.2+`: `2024b`\n- `\u003e= v0.2.1`: `2024a`\n\n## Dependencies, Development and Time zone database\n\n- No dependencies on other libraries.\n- Time zone database: `zdt` comes with [eggert/tz](https://github.com/eggert/tz). The database is compiled and shipped with `zdt` (as-is; not tar-balled or compressed).\n- if you wish to use your own version of the [IANA time zone db](https://www.iana.org/time-zones), you can set a path to it using the `-Dprefix-tzdb=\"path/to/your/tzdb\"` option. See also `zig build --help`.\n- For development: to update the time zone database and the version info, run the following build steps: `zig build update-tzdb`. Some of the code generation is done with Python scripts, which require Python \u003e= 3.9 but no third party packages, i.e. a system installation will do.\n\n## License\n\nMPL. See the LICENSE file in the root directory of the repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffobersteiner%2Fzdt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffobersteiner%2Fzdt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffobersteiner%2Fzdt/lists"}