Skip to content

Latest commit

 

History

History
230 lines (171 loc) · 5.53 KB

README.md

File metadata and controls

230 lines (171 loc) · 5.53 KB

Go Timezone CLI

A CLI Tool for timezones made using golang ⚡

What can go-timezones-cli do? ✨

  • Search for date and time based on country, or timezones.
  • Manage list for timezones you frequently view.
  • Get UTC date and time based on your local timezone or any timezones.
  • Convert time across timezones

Credits

  • Special thanks to @MitaliBhalla for the idea & feedback on the project.
  • Also thanks to @supreeth7 for providing code review & feedback on the project

Contents

Prerequisites

You will need to Go >= 1.18 installed on your computer

Installation

First clone the repository somewhere in your $PATH. A common place would be within your $GOPATH.

Option 1: Install binary

Build and copy tmz to your $GOPATH/bin:

$ make install

Option 2: Build from source

This command will build the Timezone CLI binary, named tmz. This binary will be created in the root of your project folder.

$ make build

Running the CLI

To list all commands:

$ tmz help

To run command with the full name:

$ tmz <command> [flags] <string>

NOTE: List of country codes or timezone names 🌏

Commands

Search for local date time

Search can be done via country code or country name or city name that is included in the timezone list

Usage

tmz search <search-term>
$ tmz search "us"

$ tmz search "kol"
Demo demo of search search

Search based on timezone abbreviations

To search for a timezone based on abbreviation its abbreviations e.g IST

Usage

tmz get <abbreviation> [time]
$ tmz get "ist"

$ tmz get "est"

To get the converted time at the zone provide the local time as one of the arguments

$ tmz get "jst" 10:56
Demo demo of search search

Add timezones

Timezones added to the config file are treated as the default timezones which is triggered by the tmz show --all command.

If the timezone already exists, the CLI throws an error.

config file is stored at ~/.tmz.list

Usage

tmz add <timezone>
$ tmz add "Asia/Kolkata"
Demo demo of search search

Remove timezones

Timezones are removed from the config file

Usage

tmz remove <timezone>
$ tmz remove "Asia/Kolkata"
Demo demo of search search

Show and Convert between timezones

  • This comand will help you to convert between timezones.
  • The first timezone passed as argument is set as the default timezone. Other time are calculated based on it.

Usage

tmz show <timezone1> [timezone2, timezone3 ...] [--all] [--time time]

Flags:
--all           Load all Timezones from local config
-t, --time string   Show the list at a different time
  • The --time flag will accept an time which will be used to show the list based on that time
  • The --all flag will load all the timezones saved on the config file
$ tmz show --all

$ tmz show "Asia/Jakarta" -t=10:56

Select a single timezone from defaults

To get a list of all local timezones that are saved in the config file.

Usage

tmz select

On selection it will provide an option to show the current time or convert the time based on provided local time

Demo demo of search search

Get UTC time

Get UTC time based on current system time.

Usage

tmz utc
Demo demo of search search

Get Interactive UI

Get an Interactive UI to see time across timezones.

Usage

tmz visual [timezone1, timezone2, ...] [--all]

Flags:
--all    Load all Timezones from locally saved timezones
$ tmz visual --all
$ tmz visual "Asia/Kolkata" "Europe/Berlin"
Demo demo of search search

Future Work

  • Redefined search
  • Time Format Configuration
  • Work with Daylight Savings

Feedback and Contribution

The project is open for feedback & contribution from all talented people across the globe. Feel free to reach out to me for any suggestions or improvemnts.

If there is an issue do open up a PR for the same