|
| 1 | + |
| 2 | +[](https://github.com/Neved4/twc/actions/workflows/codeql.yml) |
| 3 | + |
| 4 | +# `twc.go` - simple world clock in Go 🦦 |
| 5 | + |
| 6 | +Fast, CLI world clock that displays time zone information using |
| 7 | +[tz database] to read valid [tz entries]. |
| 8 | + |
| 9 | +```console |
| 10 | +$ twc -h -f tools/samples/tz-small.conf |
| 11 | +America/New_York 2023-12-11 12:37:13 |
| 12 | +America/Los_Angeles 2023-12-11 09:37:13 |
| 13 | +UTC 2023-12-11 17:37:13 |
| 14 | +Europe/London 2023-12-11 17:37:13 |
| 15 | +Europe/Paris 2023-12-11 18:37:13 |
| 16 | +Asia/Tokyo 2023-12-12 02:37:13 |
| 17 | +Australia/Sydney 2023-12-12 04:37:13 |
| 18 | +``` |
| 19 | + |
| 20 | +### Highlights |
| 21 | + |
| 22 | +- 🚀 _**Fast**_ - **10X times faster than [twc.c], 65X times faster than |
| 23 | + `date`**.[^1] Only ≈ `7 ms` for one entry, and ≈ `177 ms` for ≈ 600 |
| 24 | + entries. |
| 25 | +- 🔒 _**Robust**_ - tested to work with all [tz database] entries, |
| 26 | + `version 2023c`. |
| 27 | +- 📦 **Self-contained** - zero dependencies, |
| 28 | + lighweight (`1555 bytes`, `67 lines`). |
| 29 | + |
| 30 | +## Getting Started |
| 31 | + |
| 32 | +### Setup |
| 33 | + |
| 34 | +Clone the repository: |
| 35 | + |
| 36 | +```sh |
| 37 | +git clone https://github.com/Neved4/twc |
| 38 | +``` |
| 39 | + |
| 40 | +Build: |
| 41 | + |
| 42 | +```console |
| 43 | +$ go build twc.go |
| 44 | +``` |
| 45 | + |
| 46 | +### Usage |
| 47 | + |
| 48 | +``` |
| 49 | +flag provided but not defined: -z |
| 50 | +Usage of ./twc: |
| 51 | + -f string |
| 52 | + Specify file path (default "tz-small.conf") |
| 53 | + -h Print human-readable format |
| 54 | + -s string |
| 55 | + Specify time format |
| 56 | + -t string |
| 57 | + Specify timezone directly |
| 58 | +
|
| 59 | +Examples: |
| 60 | + $ twc -h -s %Y-%m-%d -t Asia/Tokyo |
| 61 | + 2006-01-02 |
| 62 | +
|
| 63 | + $ TZ=America/Los_Angeles twz |
| 64 | + 2006-01-02T15:04:05-0800 |
| 65 | +
|
| 66 | +Environment: |
| 67 | + TZ Timezone to use when displaying dates. |
| 68 | +
|
| 69 | +See also: |
| 70 | + environ(7) |
| 71 | +``` |
| 72 | + |
| 73 | +## Compatibility |
| 74 | + |
| 75 | +Runs on _**Linux**_, _**macOS**_ and _**\*BSD**_ systems on [`x86_64`] and |
| 76 | +[`arm64`], and compiles with and any other. |
| 77 | + |
| 78 | +## License |
| 79 | + |
| 80 | +`twc` is licensed under the terms of the [MIT License]. |
| 81 | + |
| 82 | +See the [LICENSE](LICENSE) file for details. |
| 83 | + |
| 84 | +[`hyperfine`]: https://github.com/sharkdp/hyperfine |
| 85 | +[`twc.c`]: https://github.com/Neved4/twc |
| 86 | +[`arm64`]: https://en.wikipedia.org/wiki/AArch64 |
| 87 | +[`x86_64`]: https://en.wikipedia.org/wiki/X86-64 |
| 88 | +[MIT License]: https://opensource.org/license/mit/ |
| 89 | +[tz database]: https://en.wikipedia.org/wiki/Tz_database |
| 90 | +[tz entries]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones |
| 91 | + |
| 92 | +[^1]: _cfr._ `date` command that takes ≈ `931 ms` for ≈ `600` entries. |
| 93 | + Measured with [`hyperfine`]. |
| 94 | +[^2]: _IEEE Std 1003.1-2017: Standard for Information Technology |
| 95 | + — Portable Operating System Interface (POSIX®)_, \ |
| 96 | + ISO/IEC/IEEE 9945:2009/COR 2:2017. URL: https://pubs.opengroup.org/onlinepubs/9699919799/ |
| 97 | +[^3]: _ISO/IEC 9899:2023: Standard for Information Technology |
| 98 | + — Programming languages — C_, ISO/IEC 9899:2023. \ |
| 99 | + URL: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf |
0 commit comments