Giter Club home page Giter Club logo

twc-go's Introduction

Go CodeQL Homebrew

twc.go - Tiny world clock in Go! ๐Ÿฆฆ

Fast, CLI world clock that displays time zone information using tz database to read valid tz entries.

$ twc -h -f tools/samples/tz-small.conf
America/New_York     2023-12-11 12:37:13
America/Los_Angeles  2023-12-11 09:37:13
UTC                  2023-12-11 17:37:13
Europe/London        2023-12-11 17:37:13
Europe/Paris         2023-12-11 18:37:13
Asia/Tokyo           2023-12-12 02:37:13
Australia/Sydney     2023-12-12 04:37:13

Highlights

  • ๐Ÿš€ Fast - 10X times faster than twc.c and 65X times faster than date.1
    Only โ‰ˆ 7 ms for one entry, and โ‰ˆ 177 ms for โ‰ˆ 600 entries.
  • ๐Ÿ”’ Robust - tested to work with all tz database entries, version 2023c.
  • ๐Ÿ“ฆ Self-contained - zero dependencies, lightweight (110 lines, 2458 bytes).

Getting Started

Setup

If you have Homebrew installed, just run:

$ brew tap Neved4/homebrew-tap/twc-go

Alternatively, clone the repository:

$ git clone https://github.com/Neved4/twc-go

Then build:

$ go build twc.go

Usage

Usage of ./twc:
  -f string
    	Specify file path (default "tz-small.conf")
  -h	Print human-readable format
  -s string
    	Specify time format
  -t string
    	Specify timezone directly

Examples:
    $ twc -h -s %Y-%m-%d -t Asia/Tokyo
        2006-01-02

    $ TZ=America/Los_Angeles twz
        2006-01-02T15:04:05-0800

Environment:
    TZ  Timezone to use when displaying dates.

See also:
    environ(7)

Docker

To compile the binary inside a Docker image, run:

docker build .

Compatibility

Runs on Linux, macOS and *BSD systems on both x86_64 and arm64.

Standards

twc.go should run on most POSIX.1-20172 compatible systems and produce ISO 86013 output.

License

twc.go is licensed under the terms of the MIT License.

See the LICENSE file for details.

Related Projects

Footnotes

  1. cfr. date command takes โ‰ˆ 931 ms when iterating over โ‰ˆ 600 entries. Measured with hyperfine. โ†ฉ

  2. IEEE Std 1003.1-2017: Standard for Information Technology โ€” Portable Operating System Interface (POSIXยฎ),
    ISO/IEC/IEEE 9945:2009/COR 2:2017. URL: https://pubs.opengroup.org/onlinepubs/9699919799/ โ†ฉ

  3. ISO 8601: Date and time \ โ€” Representations for information interchange, ISO 8601-1:2019.
    URL: https://www.iso.org/obp/ui/#iso:std:iso:8601:-2:ed-1:v1:en โ†ฉ

twc-go's People

Contributors

neved4 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

0risc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.