{"id":15140938,"url":"https://github.com/ymd-h/datetime-zig","last_synced_at":"2026-02-16T05:33:07.036Z","repository":{"id":257387223,"uuid":"858117567","full_name":"ymd-h/datetime-zig","owner":"ymd-h","description":"datetime for zig","archived":false,"fork":false,"pushed_at":"2024-09-27T23:34:42.000Z","size":87,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T01:47:37.631Z","etag":null,"topics":["datetime","zig"],"latest_commit_sha":null,"homepage":"https://ymd-h.github.io/datetime-zig/","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ymd-h.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-09-16T10:42:39.000Z","updated_at":"2024-09-27T13:42:40.000Z","dependencies_parsed_at":"2024-09-21T14:00:57.965Z","dependency_job_id":"73fd3a2e-bc50-4b57-be1a-b547d6340bc4","html_url":"https://github.com/ymd-h/datetime-zig","commit_stats":null,"previous_names":["ymd-h/datetime-zig"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ymd-h/datetime-zig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymd-h%2Fdatetime-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymd-h%2Fdatetime-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymd-h%2Fdatetime-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymd-h%2Fdatetime-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ymd-h","download_url":"https://codeload.github.com/ymd-h/datetime-zig/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymd-h%2Fdatetime-zig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29500832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T03:57:51.541Z","status":"ssl_error","status_checked_at":"2026-02-16T03:55:59.854Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["datetime","zig"],"created_at":"2024-09-26T08:42:30.511Z","updated_at":"2026-02-16T05:33:07.008Z","avatar_url":"https://github.com/ymd-h.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DateTime.zig\n\nTime Zone awared Date Time.\n\n\u003e [!WARNING]\n\u003e This project is still under development.\n\n\n## 1. Usage\n\n### 1.1 Add dependency\n\n\n```shell\nzig fetch --save git+https://github.com/ymd-h/datetime.zig#v0.0.4\n```\n\n\nIn build.zig\n\n```zig\npub fn build(b: *b.std.Build) !void {\n    const exe = b.addExecutable(\n        // (omit)\n    );\n\n    const datetime = b.dependency(\"datetime-zig\", .{ .target = .target, .optimize = .optimize });\n    exe.root_module.addImport(\"datetime\", datetime.module(\"datetime\"));\n}\n```\n\n\n\n### 1.2 Code\n\n\n```zig\nconst std = @import(\"std\");\nconst datetime = @import(\"datetime\");\nconst DateTime = datetime.DateTime;\n\npub fn main(){\n    // Create from Timestamp and TimeZone\n    const dt = DateTime.fromTimestamp(.{ .s = std.time.timestamp() }, .{});\n    _ = try DateTime.fromTimestamp(.{ .ms = std.time.milliTimestamp() }, .{});\n    _ = try DateTime.fromTimestamp(.{ .us = std.time.microTimestamp() }, .{});\n    _ = try DateTime.fromTimestamp(.{ .ns = std.time.nanoTimestamp() }, .{});\n    _ = try DateTime.fromTimestamp(.{ .s = std.time.timestamp() }, .{ .hour = 2, .minute = 30 });\n\n    // Parse ISO8601 date string\n    const dt2 = try DateTime.parse(\"2024-09-15T11:15:23.987+09:00\");\n\n    // Format ISO8601\n    var w = std.io.bufferedWriter(std.iogetStdOut().writer());\n    const stdout = bw.writer();\n    try dt.formatISO8601(stdout, .{ .format = .extended, .resolution = .ms });\n    try stdout.print(\"\\n\", .{});\n    try bw.flush();\n\n    // Custom Format\n    try dt.formatCustom(stdout, \"%Y/%m/%d %H:%M:%S.%f %:z\\n\");\n\n\n    // Compare DateTime\n    _ = try dt.earlierThan(dt2);\n    _ = try dt.laterThan(dt2);\n    _ = try dt.equal(dt2);\n\n\n    // Get Timestamp (elapsed time from 1970-01-01T00:00:00Z)\n    _ = try dt.getTimestamp(); // i64\n    _ = try dt.getMilliTimestamp(); // i64\n    _ = try dt.getMicroTimestamp(); // i64\n    _ = try dt.getNanoTimestamp(); // i128\n\n\n    // Get day of week\n    _ = try dt.dayOfWeek(); // enum { .Sunday, .Monday, .Tuesday, .Wednesday, .Thursday, .Friday, .Saturday }\n\n\n    // Sort\n    var dates = [_]Date{ dt, dt2 };\n    try DateTime.sort(\u0026dates, .asc);\n    try DateTime.sort(\u0026dates, .desc);\n}\n```\n\nSince fields can be changed from outside freely,\nmethods validate its values and fail unless it is valid.\n\n\nLeap second (`.second = 60`) is accepted and can be compared,\nhowever, it will be ignored when exporting to UNIX timestamp.\n\n\n## 2. Features\n- Construct `DateTime` from `Timestamp` and `TimeZone`\n- Get timestamp with resolution of second, milli second, micro second, and nano second\n- Change `TimeZone`\n- Parse ISO8601 basic and extended format\n- Write ISO8601 basic and extended format, or custom format\n- Compare two `DateTime`\n- Sort `DateTime` slice\n- `floor()` and `ceil()` with resolution of century, year, hour, date, hour, minute, second, milli second, micro second, and nano second.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymd-h%2Fdatetime-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fymd-h%2Fdatetime-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymd-h%2Fdatetime-zig/lists"}