Skip to content

joaonunatings/tec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tec — Time Expression Calculator

tec is a small command-line tool that evaluates time expressions using the same rules as calculator.net’s time calculator: each value is a number followed by a unit (d days, h hours, m minutes, s seconds). You can combine several values in one term with spaces, and combine terms with + or -.

What it does

  • Parses expressions like 1d 2h 3m 4s + 4h 5s - 2030s.
  • Prints a breakdown of the result in days/hours/minutes/seconds and equivalent totals in each unit.

Requirements

  • Go 1.22 or newer (only for building from source).

Install

Prebuilt binaries (recommended)

  1. Open the Releases page on GitHub.

  2. Download the archive or binary for your platform:

    Platform Asset name
    Linux x86_64 tec-linux-amd64
    Linux ARM64 tec-linux-arm64
    macOS Intel tec-darwin-amd64
    macOS Apple Silicon tec-darwin-arm64
    Windows x86_64 tec-windows-amd64.exe
  3. Verify integrity (optional): the file SHA256SUMS lists checksums for each binary.

    sha256sum -c SHA256SUMS
  4. Install the binary on your PATH (examples):

    # Linux / macOS
    chmod +x tec-linux-amd64
    sudo mv tec-linux-amd64 /usr/local/bin/tec

    On Windows, place tec-windows-amd64.exe in a folder that is on your PATH and rename it to tec.exe if you like.

Build from source

git clone https://github.com/joaonunatings/tec.git
cd tec
go build -o tec .

Install:

go install github.com/joaonunatings/tec@latest

(Ensure $GOPATH/bin or $(go env GOPATH)/bin is on your PATH.)

Usage

tec <expression>

Expression rules

  • Each value is a number (integer or decimal) immediately followed by one of d, h, m, s (case-insensitive for the unit letter).
  • Inside a term, multiple values are separated by whitespace (e.g. 1d 2h 3m 4s).
  • Terms are separated only by + or - (spaces do not split terms; 15m 15m is one term, 15m + 15m is two terms).

Examples

tec "15m 15m"
tec 15m + 15m
tec 1d 2h 3m 4s + 4h 5s - 2030s

If you omit arguments, tec prints a short usage message to stderr.

Development

Clone the repository:

git clone https://github.com/joaonunatings/tec.git
cd tec

Run tests:

make test
# or
go test -v ./...

Build a local binary:

make build
# produces ./tec

Cross-compile all release targets (writes to ./dist/):

make release

Release workflow (maintainers)

Releases are built automatically by GitHub Actions when a semantic version tag is pushed to the repository, and the tagged commit is on main.

  1. Commit your changes on main.

  2. Create an annotated tag (example v1.0.0):

    git tag -a v1.0.0 -m "v1.0.0"
    git push origin main
    git push origin v1.0.0

Tag names should follow SemVer with a v prefix, for example v1.2.3 or v1.2.3-rc.1.

The workflow publishes a GitHub Release named after the tag, attaches all platform binaries under dist/ naming, and includes SHA256SUMS.

License

This project is licensed under the MIT License.

About

Time Expression Calculator CLI

Resources

License

Stars

Watchers

Forks

Contributors