{"id":15049246,"url":"https://github.com/neved4/twc","last_synced_at":"2025-04-10T02:04:03.589Z","repository":{"id":211616353,"uuid":"729586838","full_name":"Neved4/twc","owner":"Neved4","description":"⌚️ Tiny world clock in C!","archived":false,"fork":false,"pushed_at":"2025-03-21T23:49:39.000Z","size":48,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-22T00:26:20.238Z","etag":null,"topics":["c","c99","cli","clock","command","command-line-tool","date","datetime","iso","iso8601","line","posix","terminal","time-zones","tool","tz","tzinfo"],"latest_commit_sha":null,"homepage":"","language":"C","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/Neved4.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-12-09T17:42:51.000Z","updated_at":"2025-03-21T23:49:42.000Z","dependencies_parsed_at":"2023-12-16T22:40:20.383Z","dependency_job_id":"ae88e9df-6dbc-421c-8400-7f91ad0a54a5","html_url":"https://github.com/Neved4/twc","commit_stats":null,"previous_names":["neved4/wcs","neved4/swc","neved4/twc"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neved4%2Ftwc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neved4%2Ftwc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neved4%2Ftwc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neved4%2Ftwc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neved4","download_url":"https://codeload.github.com/Neved4/twc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142948,"owners_count":21054671,"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":["c","c99","cli","clock","command","command-line-tool","date","datetime","iso","iso8601","line","posix","terminal","time-zones","tool","tz","tzinfo"],"created_at":"2024-09-24T21:19:15.746Z","updated_at":"2025-04-10T02:04:03.577Z","avatar_url":"https://github.com/Neved4.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![C](https://img.shields.io/badge/ISO_C17-A8B9CC?logo=c\u0026logoColor=fff)][C17]\n[![IEEE](https://img.shields.io/badge/POSIX.1\u0026#8209;2024-00629B?logo=ieee\u0026logoColor=fff)][POSIX.1-2024]\n[![CodeQL](https://github.com/github/docs/actions/workflows/codeql.yml/badge.svg)](https://github.com/Neved4/twc/actions/workflows/codeql.yml)\n[![Homebrew](https://img.shields.io/badge/Homebrew-tap-2AAB47?logo=homebrew\u0026logoColor=959DA5\u0026labelColor=2B3137)](https://github.com/Neved4/homebrew-tap/blob/main/Formula/gotwc.rb)\n\n# `twc` - Tiny world clock in C! 🛠️\n\nFast, CLI world clock that displays time zone information using\n[tz database] to read valid [tz entries].\n\nIt works similar to [zdump(8)], but it lets you format the output more\nprecisely:\n\n```console\n$ twc -h -f tools/samples/tz-small.conf\nAmerica/New York     2024-12-10  16:39:43  -0500\nAmerica/Los Angeles  2024-12-10  13:39:43  -0800\nUTC                  2024-12-10  21:39:43  +0000\nEurope/London        2024-12-10  21:39:43  +0000\nEurope/Paris         2024-12-10  22:39:43  +0100\nAsia/Tokyo           2024-12-11  06:39:43  +0900\nAustralia/Sydney     2024-12-11  08:39:43  +1100\n```\n\n### Highlights\n\n- 🚀 _**Fast**_ - 5X times faster than `date`.[^1] Only ≈ `8 ms` for one\n  entry, and ≈ `177 ms` for ≈ 600 entries.\n- 🔒 _**Robust**_ - tested to work with all [tz database] entries,\n  [`version 2024b`].\n- 📦 _**Self-contained**_ - zero dependencies, ISO C17,\n  lightweight (`175 lines`, `3235 bytes`).\n\n## Getting Started\n\n### Prerequisites\n\nIf you are building [`twc`], you'll need:\n\n- A [C] compiler that supports [C99] or later.\n- A system with a working `asprintf` implementation.\n- If `asprintf` is not present, you can use [Neved4/asprintf].\n\n### Installing\n\nIf you have [Homebrew] installed, just run:\n```shell\nbrew install Neved4/homebrew-tap/twc\n```\n\n### Building\n\nClone the repository:\n\n```shell\ngit clone https://github.com/Neved4/twc\n```\n\nBuild the sources:\n\n```shell\nmake twc\n```\n\nAlternatively, if you have [`zig`] installed:\n```shell\nzig cc twc.c -o twc\n```\n\n### Usage\n\nThese are the options available:\n\n```text\ntwc [-h] [-f path] [-s format] [-t timezone] ...\n\nOptions:\n  -f path\n      Read config from path (default \"$HOME/.config/twc/tz.conf\")\n  -h\n      Print in human-readable format\n  -s format\n      Set desired time format (e.g. \"%Y-%m-%d\")\n  -t timezone\n      specific timezone (e.g. \"Asia/Tokyo\")\n\nExamples:\n  Print Tokyo date in a human-readable format with YY-MM-DD format:\n\n    $ twc -h -s %Y-%m-%d -t Asia/Tokyo\n    2024-01-02\n\n  Print date in Los Angeles using an environment variable for the timezone:\n\n    $ TZ=America/Los_Angeles twc\n    2024-01-02T15:04:05-0800\n\nEnvironment:\n  TZ\n    Timezone to use when displaying dates.\n  XDG_CONFIG_HOME\n    When defined, it will be used to store the tz.conf file.\n\nFiles:\n  ~/.config/twc/tz.conf\n    Stores tz database entries to be displayed.\n\nSee also:\n    time(3), strftime(3), environ(7)\n```\n\n### Docker\n\nTo compile the binary inside a [Docker] image, run:\n```shell\ndocker build .\n```\n\n## Compatibility\n\nRuns on _**Linux**_, _**macOS**_ and _**\\*BSD**_ systems on [`x86_64`] and\n[`arm64`], and compiles with [`zig`], [`clang`], [`gcc`], [`tcc`] and any other\ncompiler that supports [C17] or later.\n\nAlso builds on any [C99] compiler on systems that supports and have\n`asprintf()`.\n\n## Standards\n\n`twc` is compatible with [POSIX.1-2024][][^2] as well as [C23][][^3], and\nit outputs [ISO 8601][][^4] format.\n\n## See Also\n\nVarious [`zdump`][zdump(8)] implementations:\n\n- [glibc - zdump.c](https://github.com/apple-oss-distributions/system_cmds/blob/main/zdump/zdump.c)\n- [apple - zdump.c](https://github.com/apple-oss-distributions/ICU/blob/main/icu/icu4c/source/tools/tzcode/zdump.c#L94)\n- [FreeBSD - zdump.c](https://github.com/freebsd/freebsd-src/blob/main/contrib/tzcode/zdump.c)\n- [OpenBSD - zdump.c](https://github.com/openbsd/src/blob/master/usr.sbin/zdump/zdump.c)\n- [Boruch Baum - zdump3](https://github.com/Boruch-Baum/zdump-3-/blob/master/zdump3.c)\n\n## Acknowledgments\n\nSpecial thanks to everybody who helped me with pointers and memory allocation,\n[@navi](https://git.vlhl.dev/navi), [@enigmatico](https://gitlab.com/enigmatico)\nand [@K4rakara](https://github.com/K4rakara/) for their code reviews, and thx to\n[@lexiwitch](https://github.com/lexiwitch), for getting me started.\n\n## License\n\n`twc` is licensed under the terms of the [MIT License].\n\nSee the [LICENSE](LICENSE) file for details.\n\n[Neved4/asprintf]: https://github.com/Neved4/asprintf\n[`twc`]: https://github.com/Neved4/twc\n[`hyperfine`]: https://github.com/sharkdp/hyperfine\n[`arm64`]: https://en.wikipedia.org/wiki/AArch64\n[`x86_64`]: https://en.wikipedia.org/wiki/X86-64\n[`clang`]: https://clang.llvm.org/\n[`gcc`]: https://gcc.gnu.org/\n[`tcc`]: https://bellard.org/tcc/\n[`zig`]: https://ziglang.org/\n[MIT License]: https://opensource.org/license/mit/\n[C]: https://en.wikipedia.org/wiki/C_(programming_language)\n[C99]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n[C17]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf\n[C23]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf\n[POSIX.1-2024]: https://pubs.opengroup.org/onlinepubs/9799919799/\n[ISO 8601]: https://www.iso.org/obp/ui/#iso:std:iso:8601:-2:ed-1:v1:en\n[tz database]: https://en.wikipedia.org/wiki/Tz_database\n[tz entries]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n[`version 2024b`]: https://www.iana.org/time-zones\n[Docker]: https://www.docker.com/\n[Homebrew]: https://brew.sh/\n[zdump(8)]: https://man.freebsd.org/cgi/man.cgi?query=zdump\u0026apropos=0\u0026sektion=0\u0026manpath=FreeBSD+7.0-RELEASE\u0026format=html\n\n[^1]: _cfr._ `date` command takes ≈ `931 ms` when iterating over ≈ 600\n    entries. Measured with [`hyperfine`].\n[^2]: _IEEE Std 1003.1-2024: Standard for Information Technology\n    — Portable Operating System Interface (POSIX®)_, \\\n    ISO/IEC DIS 9945. URL: https://pubs.opengroup.org/onlinepubs/9799919799/\n[^3]: _ISO/IEC 9899: Standard for Information Technology\n    — Programming languages — C_, ISO/IEC 9899:2023. \\\n    URL: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf\n[^4]: _ISO 8601: Date and time — Representations for information interchange_, ISO 8601-1:2019. \\\n    URL: https://www.iso.org/obp/ui/#iso:std:iso:8601:-2:ed-1:v1:en\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneved4%2Ftwc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneved4%2Ftwc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneved4%2Ftwc/lists"}