Gotz: A simple CLI timezone info tool

gotz

gotz - a simple CLI timezone info tool.

Installation

Directly via Go

go install github.com/merschformann/gotz@latest

Binary

Simply download the binary of the latest release (look for gotz_OS_ARCH), rename it to gotz and put it in a folder in your $PATH.

Usage

Show current time:

gotz

preview

Show arbitrary time:

gotz 15

preview

Time can be one of the following formats:

15
15:04
15:04:05
3:04pm
3:04:05pm
3pm
1504
150405
2006-01-02T15:04:05

Basic configuration

Set the timezones to be used by default:

gotz --timezones "Office:America/New_York,Home:Europe/Berlin"

(lookup timezones in the timezones wiki page - TZ database name column)

Set 12-hour format:

gotz --hours12 true

Customization

The configuration is stored in $HOME/.gotz.config.json. It can be configured directly or via the arguments of the gotz command (see gotz --help). The configuration attributes are described in the following example:

{
    // Configures how the day is segmented
    "day_segments": {
        // Hour of the morning to start (0-23)
        "morning": 6,
        // Color of the morning segment (named color or terminal color code)
        "morning_color": "red",
        // Hour of the day (business hours / main time) to start (0-23)
        "day": 8,
        // Color of the day segment (named color or terminal color code)
        "day_color": "yellow",
        // Hour of the evening to start (0-23)
        "evening": 18,
        // Color of the evening segment (named color or terminal color code)
        "evening_color": "blue",
        // Hour of the night to start (0-23)
        "night": 22,
        // Color of the night segment (named color or terminal color code)
        "night_color": "red"
    },
    // Configures the timezones to be shown
    "timezones": [
        // Timezones have a name (Name) and timezone code (TZ)
        { "Name": "Office", "TZ": "America/New_York" },
        { "Name": "Home", "TZ": "Europe/Berlin" },
    ],
    // Select symbols to use for the time blocks (one of 'mono', 'rectangles' or 'sun-moon')
    "symbols": "rectangles",
    // Indicates whether to plot tics for the local time
    "tics": false,
    // Indicates whether to stretch across the full terminal width (causes inhomogeneous segment lengths)
    "stretch": true,
    // Indicates whether to colorize the blocks
    "colorize": false,
    // Indicates whether to use 12-hour format
    "hours12": false
}

Why?

Working in an international team is a lot of fun, but comes with the challenge of having to deal with timezones. Since I am not good at computing them quickly in my head, I decided to write a simple CLI tool to help me out. I hope it can be useful for other people as well. Thanks for the inspiration @sebas!

Owner
Comments
  • Inline Timezone Bars?

    Inline Timezone Bars?

    Would it be possible to have the bars shown inline with the labels? I find it hard to read when the bars are underneath. Maybe something like this:

                                                                       now v 07:47
                                                                            | 
    Local : Thu 28 Jul 2022 07:47                               ▒▒▒▒▒▒████████████████████████████████████████████████▒▒▒▒▒▒▒▒▒▒▒▒
                                                                            | 
    SF    : Thu 28 Jul 2022 07:47                            ▒▒▒▒▒▒████████████████████████████████████████████████▒▒▒▒▒▒▒▒▒▒▒▒
                                                                            | 
    IST   : Thu 28 Jul 2022 20:17 ▒▒▒▒▒████████████████████████████████████████████████▒▒▒▒▒▒▒▒▒▒▒▒      
    
  • Aggressive Config File Behavior

    Aggressive Config File Behavior

    I like the idea of creating a known-good config file at startup, but replacing the user's custom config file with the defaults when a syntax error has been found seems very aggressive. It means the user is just one typo away from having their carefully tailored configuration getting blown away without warning. Since I'm posting this, I bet you can probably guess what just happened to me...

    It seems safer behavior would simply be to exit with an error message if the configuration file cannot be parsed. At the very least, the user should be given the chance to cancel before their custom configuration is replaced.

  • If color enabled, use solid block for night

    If color enabled, use solid block for night

    Basically, this checks to see if colors are enabled, and if so, uses the same solid block character for day and night in "rectangles" mode. I can see why you would want to use blank character for night if color mode is off, but since we are able to set different colors for day and night, there's no conflict when using the same character.

    The following shows the difference when switching "colorize" from false to true:

    nightblock

    For me personally, the ability to set a night color makes more visual sense than just leaving the space blank.

  • Custom symbol support

    Custom symbol support

    Description

    Adds support for custom symbols and a plain all blocks symbol mode.

    Changes

    • Adds support for user-defined custom symbols
    • Adds an all blocks symbol mode
    • Fixes the color of the current time marker (same color for whole marker)
  • missing tzdata for windows release

    missing tzdata for windows release

    gotz doesn't output correctly on the windows release (and I think I know why).

    Here is a screenshot of a default configuration running with the local time being Eastern Standard:

    image

    Here is a command-line bork on a manual entry:

    image

    Now, I'm not a go developer but it's a lovely language and easy to follow. In configuration.go and in args.go there is use of the time::Location.LoadLocation(name) function.

    Docs state:

    LoadLocation looks for the IANA Time Zone database in the following locations in order:

    • the directory or uncompressed zip file named by the ZONEINFO environment variable - on a Unix system, the system standard installation location - $GOROOT/lib/time/zoneinfo.zip - the time/tzdata package, if it was imported.

    Windows doesn't have an IANA database and also doesn't run a ZONEINFO env var. But, what's this about time/tzdata?

    This package will be automatically imported if you build with -tags timetzdata.

    I think the easiest fix is in your build script, if you add -tags timetzdata to line 23? Maybe you don't want to do that for unix systems, maybe add another variable and add it with the name change on line 19?

    In any case, I love simple TUI command-line tools and yours is spiffy. I love using them as practice to learn or reinforce languages and I'm porting gotz to .NET in F# and C# and I hope to have the F# port done in another day or so. :)

  • Feature request: Allow gotz to remain opened and update continuously

    Feature request: Allow gotz to remain opened and update continuously

    I'd like to keep gotz opened and glance at it without running the command. Ideally this is a flag or configuration value with maybe a sane update interval that can also be configured. I don't need 60 FPS for this, for example, or even every second. Minutes?

  • Adds inline option

    Adds inline option

    Description

    Adds the inline option which plots location & time info on one line with the bars.

    Changes

    • Adds the inline option
      • Activate via --inline true

    Preview

    draft

  • Enables requesting specific time in different timezone

    Enables requesting specific time in different timezone

    Description

    Enables requesting a specific time in a different timezone (via their indices).

    Changes

    • Request specific time in one of the configured timezones
      • E.g., use gotz 15@2 to check 3 pm in timezone at index 2
      • Note that index 0 is always the local timezone
  • Includes tz data in binary

    Includes tz data in binary

    Description

    This PR modifies the build script to include timezone data (see here), which reduces dependence on local availability of the information.

    Changes

    • Includes tzdata during build

    Resolves #8

  • Add support for JSONC config file

    Add support for JSONC config file

    By running the config file through this JSONC converter (https://github.com/tidwall/jsonc), comments and trailing commas won't be picked up as errors and can remain in the file without effecting any of the syntax.

    With this change the example configuration file in the README can be pasted in config.json and used as-is, which makes it a bit easier for new users to customize their setup.

    P.S. This is first time I've actually worked with Go, so apologies if I've missed something.

  • Use XDG basedir for config files

    Use XDG basedir for config files

    This patch makes gotz use XDG Base Directory Specification config directory.

    https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Related tags
Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Jan 12, 2022
Symfony-cli - The Symfony CLI tool For Golang

Symfony CLI Install To install Symfony CLI, please download the appropriate vers

Dec 28, 2022
bcrypt-cli is the CLI tool for hashing passwords with bcrypt.

bcrypt-cli bcrypt-cli is the CLI tool for hashing passwords with bcrypt. Install go install github.com/ryicoh/bcrypt-cli Usage It can be used like bas

Jan 9, 2023
GTDF-CLI - The official CLI tool to operate with Getting Things Done Framework
GTDF-CLI - The official CLI tool to operate with Getting Things Done Framework

This is the official CLI tool to operate with Getting Things Done Framework. How

Feb 14, 2022
News-parser-cli - Simple CLI which allows you to receive news depending on the parameters passed to it
News-parser-cli - Simple CLI which allows you to receive news depending on the parameters passed to it

news-parser-cli Simple CLI which allows you to receive news depending on the par

Jan 4, 2022
This tool is a CLI-interactive tool for TA who use eeclass platform

NTHU eeclass TA helper. This tool is a CLI-interactive tool for TA who use eeclass platform. It helps TA to download all the submitted homework, and use CSV to record the score and comment, and upload CSV score directly to the eeclass platform with just 2 Enter key!

Dec 11, 2021
Got: Simple golang package and CLI tool to download large files faster 🏃 than cURL and Wget!

Got. Simple and fast concurrent downloader. Installation ❘ CLI Usage ❘ Module Usage ❘ License Comparison Comparison in cloud server: [root@centos-nyc-

Dec 29, 2022
Just a simple CLI tool to group dependabot PRs by dependency and merge them.
Just a simple CLI tool to group dependabot PRs by dependency and merge them.

Dependabotbot Have you been the victim of a lodash update? Has your notification page in Github been assaulted by needing to update a patch version of

Jun 30, 2022
A very very simple CLI tool to know the next and previous SpaceX flights.

Rocket A very very simple CLI tool to know the next and previous SpaceX flights. Commands rocket Get the next flight. rocket latest Get the last fligh

Apr 19, 2021
A simple script to run speedtest(offical) CLI tool and store the results in CSV

PeriodicBW A script made to run official speedtest.net binary periodically and store the results in a CSV file Installation Get the official speedtest

Aug 10, 2021
Jan 3, 2023
gon is a simple, no-frills tool for signing and notarizing your CLI binaries for macOS
gon is a simple, no-frills tool for signing and notarizing your CLI binaries for macOS

Sign, notarize, and package macOS CLI tools and applications written in any language. Available as both a CLI and a Go library.

Jan 4, 2023
A simple CLI tool that identifies duplicate JARS in a directory. It can remove them also if desired.

Mendix Userlib Cleaner This little utility can be used to identify and clean duplicate JARs. It was created mainly for Mendix apps due to lack of form

Nov 15, 2022
A simple CLI tool to use the _simulate API of elasticsearch to quickly test pipelines

elasticsearch-pipeline-tester A simple CLI tool to use the _simulate API of elasticsearch to quickly test pipelines usage: pipelinetester [<flags>] <p

Oct 19, 2021
kcon is a simple CLI tool to switch the context of your Kubeconfig file.

kcon kcon is a simple CLI tool to switch the context of your Kubeconfig file. Scope The code published here is educational only. Usage Usage of kcon:

Oct 14, 2021
A simple CLI tool to help you manage your CPU

gocpu A simple cli tool to handle and watch your CPU. Usage Usage gocpu [subcommand] [flags] subcommand: watch - see the realtime cpu frequenc

Nov 29, 2021
Simple CLI tool for creating gotd sessions.

Simple CLI tool for creating gotd sessions.

Sep 29, 2022
eksctl is a simple CLI tool for creating clusters on EKS
eksctl is a simple CLI tool for creating clusters on EKS

eksctl is a simple CLI tool for creating clusters on EKS - Amazon's new managed Kubernetes service for EC2. It is written in Go, and uses CloudFormation.

Jan 7, 2023
A dead simple CLI tool that prints the next semantic version based on the last tag of your git repository

nextver A dead simple CLI tool that prints the next semantic version based on the last tag of your git repository. Install go install github.com/junk1

Sep 29, 2022