{"id":16860528,"url":"https://github.com/moreati/python-tai64","last_synced_at":"2025-04-05T11:27:16.211Z","repository":{"id":172504511,"uuid":"649374913","full_name":"moreati/python-tai64","owner":"moreati","description":"TAI64, TAI64N, TAI64NA implementations for Python.","archived":false,"fork":false,"pushed_at":"2024-05-13T11:25:31.000Z","size":30,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T00:35:24.558Z","etag":null,"topics":["libtai","tai","tai64","tai64n","time"],"latest_commit_sha":null,"homepage":"","language":"Python","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/moreati.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":"2023-06-04T16:44:49.000Z","updated_at":"2024-05-13T11:25:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"25d54499-c7e9-4dd9-ad4d-4df8ddeec876","html_url":"https://github.com/moreati/python-tai64","commit_stats":null,"previous_names":["moreati/python-tai64"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moreati%2Fpython-tai64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moreati%2Fpython-tai64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moreati%2Fpython-tai64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moreati%2Fpython-tai64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moreati","download_url":"https://codeload.github.com/moreati/python-tai64/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247328183,"owners_count":20921145,"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":["libtai","tai","tai64","tai64n","time"],"created_at":"2024-10-13T14:25:02.655Z","updated_at":"2025-04-05T11:27:16.166Z","avatar_url":"https://github.com/moreati.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python TAI64\n\nTAI64, TAI64N, TAI64NA implementations for Python.\n\n[International Atomic Time (TAI)][TAI] is the basic standard for measuring time.\nUniversal Coordinated Time (UTC) is derived from TAI by adding or subtracting\nleap seconds according to the measured rotation speed of the Earth.\n\n[TAI64] is a family of formats for TAI times, first implemented in [libtai].\nThey have well known serialisations to bytes or hexadecimal.\n\n| Format  | Bytes |         Resolution       |       Range       |\n| ------- | ----: | -------------------------| ----------------- |\n| TAI64   |     8 | 1 second                 | 292 billion years |\n| TAI64N  |    12 | 1 nanosecond (10**-9 s)  | 292 billion years |\n| TAI64NA |    16 | 1 attosecond (10**-18 s) | 292 billion years |\n\n## Usage\n\nThe epoch for TAI64 is 1970-01-01 00:00:00 TAI, this is assigned the integer value 2**62.\n\n```pycon\n\u003e\u003e\u003e import tai64\n\u003e\u003e\u003e tai64.tai(sec=tai64.EPOCH)\ntai64.tai(4611686018427387904)\n```\n\nTo deserialise a TAI64, TAI64N, or TAI64NA call the `from_hex()` or\n`unpack()` class method.\n\n```pycon\n\u003e\u003e\u003e tai64.tai.from_hex('400000001dc03c40')\ntai64.tai(4611686018926525504)\n\u003e\u003e\u003e tai64.tai.unpack(b'@\\x00\\x00\\x00\\x1d\\xc0\u003c@')\ntai64.tai(4611686018926525504)\n```\n\nTo serialise call the `hex()` or `pack()` method\n\n```pycon\n\u003e\u003e\u003e tai64.tai(4611686018926525504).hex()\n'400000001dc03c40'\n\u003e\u003e\u003e tai64.tai(4611686018926525504).pack()\nb'@\\x00\\x00\\x00\\x1d\\xc0\u003c@'\n```\n\nFor nanosecond precision (9 decimal places) use `tai64.tain()`,\nor for attosecond (18 decimal places) use `tai64.taia()`.\n\n```pycon\n\u003e\u003e\u003e tai64.tain(4611686018926525504, nano=123).hex()\n'400000001dc03c400000007b'\n\u003e\u003e\u003e tai64.taia(4611686018926525504, nano=1193046, atto=11259375).hex()\n'400000001dc03c400012345600abcdef'\n\u003e\u003e\u003e tai64.taia.unpack(b'@\\x00\\x00\\x00\\x1d\\xc0\u003c@\\x00\\x124V\\x00\\xab\\xcd\\xef')\ntai64.taia(4611686018926525504, 1193046, 11259375)\n```\n\n## TODO\n\n- Implement TAI64 \u003c-\u003e UTC\n- PyPI package\n- Docstrings\n- Decide: should `tai()` take raw unsigned int (current behaviour) or offset from epoch (`time.time()` behaviour)\n- Decide and implement exceptions hierarchy\n- Decide and implement `format()` behaviour\n- Decide `int()` behaviour of TAI64N and TAI64NA\n- Decide `__floor__()` et al\n- Decide arithmatic behaviour\n- Investigate `CLOCK_TAI`\n\n## Other implementations\n\n- [calends] for Go, C/C++, Dart, Javascript, WASM, and PHP\n- [Go cactus/tai64]\n- [Go paulhammond/tai64]\n- [Javascript tai64]\n- [libtai] original C implementation, by D. J. Bernstein.\n- [Perl Time::TAI64]\n- [Python tai64n]\n- [Python taiconverter]\n- [Rust tai64]\n\n## Further Reading\n\n- https://en.wikipedia.org/wiki/International_Atomic_Time\n- https://cr.yp.to/proto/utctai.html\n- https://cr.yp.to/libtai/tai64.html\n- https://cr.yp.to/libtai.html\n\n[TAI]: https://en.wikipedia.org/wiki/International_Atomic_Time\n[TAI64]: https://cr.yp.to/libtai/tai64.html\n[calends]: https://calends.readthedocs.io/en/latest/\n[Go cactus/tai64]: https://github.com/cactus/tai64\n[Go paulhammond/tai64]: https://github.com/paulhammond/tai64\n[Javascript tai64]: https://www.npmjs.com/package/tai64\n[libtai]: https://cr.yp.to/libtai.html\n[Perl Time::TAI64]: https://metacpan.org/pod/Time::TAI64\n[Python tai64n]: https://pypi.org/project/tai64n/\n[Python taiconverter]: https://pypi.org/project/tai64converter/\n[Rust tai64]: https://docs.rs/tai64/latest/tai64/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoreati%2Fpython-tai64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoreati%2Fpython-tai64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoreati%2Fpython-tai64/lists"}