When - Timezones from the command line

Related tags

Command-line when
Overview

example

when: a timezone utility for the command line

Build Status Crates.io License

$ when "now in vienna"

when is a small utility which tells you what time it is somewhere or what some time is somewhere. You can use it from the command line or uses it online from the browser.

These are some input examples:

  • now
  • 2 hours ago in yyz
  • 5pm in yyz -> sfo
  • 5pm in vienna -> london
  • 4pm on 17.05.2021 in vienna -> tokyo
  • 4pm yesterday in vienna -> vienna va
  • in 4 hours in san francisco
  • 2pm in 2 days in new delhi
  • now in yyz -> sfo -> vie -> lhr
  • unix 1639067620 in tokyo

Installation

Conveniently via cargo:

$ cargo install when-cli

There is also an online version you can use from your browser.

Note that this project requires a Rust 2021 compatible compiler (1.56.0 or later). Attempting to install this package on an older compiler will result in compilation errors (feature `edition2021` is required). If you're using rustup make sure to update (rustup update), you might be on an older version.

Usage

Basically takes a single argument which is a string which describes the format in roughly this syntax. Both locations are optional. The "local" location always refers to the current machine's timezone.

time and date in location -> other location

Multiple locations can be suplied by using the arrow operator multiple times. This means you can do things like now in yyz -> sfo -> vie.

Time and date can be provided roughly like this:

  • 2:30pm, 14:30, 7:00, now
  • 14:30 tomorrow
  • 14:30
  • 17:00 on 20.05. (DD.MM.)
  • 17:00 on 20.05.2020 (DD.MM.YYYY)
  • relative times (in 4 hours or 4 hours ago)
  • unix timestamps (unix:TS or unix TS)

For locations many major cities are supported as well as common timezone names like Europe/Vienna. A certain amount of disambiugation is possible with city names. For instance Vienna VA (Virginia) is different than Vienna AT (Austria).

Comments
  • [Feature request] Days since/in X days

    [Feature request] Days since/in X days

    Thank you for an interesting tool!

    I was wondering if the following use-case would be interesting to you: I frequently want to know how much days have passed since a certain date or what would be the date + x days. IIUC, I can already calculate now + x days through 4 pm in x days but I can't do the same for the future and the past. It would certainly be nice to me since that's something I frequently do to calculate some documents processing time, etc.

    opened by kirillbobyrev 4
  • not working in rust 1.54.0 // ubuntu 20.04

    not working in rust 1.54.0 // ubuntu 20.04

    Hello @mitsuhiko thanks for making this project open source. Wish I could buy you a beer or coffee.

    I tried to installed it today but came across this issue:

    $ cargo install when-cli
    
        Updating crates.io index
      Downloaded when-cli v0.4.0
    error: failed to parse manifest at `/home/pathcl/.asdf/installs/rust/1.54.0/registry/src/github.com-1ecc6299db9ec823/when-cli-0.4.0/Cargo.toml`
    
    Caused by:
      feature `edition2021` is required
    
      this Cargo does not support nightly features, but if you
      switch to nightly channel you can add
      `cargo-features = ["edition2021"]` to enable this feature
    
    $ cargo --version
    cargo 1.54.0 (5ae8d74b3 2021-06-22)
    
    $ rustc --version
    rustc 1.54.0 (a178d0322 2021-07-26)
    

    Maybe I missed something in the readme?

    opened by pathcl 3
  • error: could not find `when-cli` in registry `crates-io` with version `*`

    error: could not find `when-cli` in registry `crates-io` with version `*`

    When trying to install when-cli using cargo, I am getting this output

    ❯ cargo install when-cli
        Updating crates.io index
    error: could not find `when-cli` in registry `crates-io` with version `*`
    

    Can you let me know, what am I doing wrong?

    opened by khushmeeet 2
  • Add binary target to use

    Add binary target to use "cargo install"?

    I often use https://time.is to convert timezones, getting this from the CLI would be neat! However, when running cargo install when i get this:

    error: there is nothing to install in `when v0.1.4`, because it has no binaries
    `cargo install` is only for installing programs, and can't be used with libraries.
    To use a library crate, add it as a dependency in a Cargo project instead.
    

    Could you add a binary target to solve this? Thanks!

    opened by IngwiePhoenix 2
  • error[E0658]: use of unstable library feature 'proc_macro_is_available'

    error[E0658]: use of unstable library feature 'proc_macro_is_available'

    cargo install when-cli error:

    error[E0658]: use of unstable library feature 'proc_macro_is_available'
      --> /Users/thearas/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.33/src/detection.rs:28:21
       |
    28 |     let available = proc_macro::is_available();
       |                     ^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: see issue #71436 <https://github.com/rust-lang/rust/issues/71436> for more information
       = help: add `#![feature(proc_macro_is_available)]` to the crate attributes to enable
    
    For more information about this error, try `rustc --explain E0658`.
    error: could not compile `proc-macro2` due to previous error
    warning: build failed, waiting for other jobs to finish...
    error: failed to compile `when-cli v0.1.0`, intermediate artifacts can be found at `/var/folders/wb/ss6s2j2n1nj5jl5_v_qy2br40000gn/T/cargo-installFv9jfm`
    
    Caused by:
      build failed
    

    Version

    rustc 1.57.0-nightly (b69fe5726 2021-09-10)

    opened by Thearas 1
  • Problems with 12am/12pm

    Problems with 12am/12pm

    Times such as "12am" or "12pm" don't seem to work correctly now. For example, I want to compare times in Montreal and Berlin.

    Behaviour for any time other than 12am/pm — works normally:

    $ when "5pm in montreal -> berlin"
    time: 17:00:00
    date: 2021-12-04
    location: Montreal (Canada)
    zone: America/Toronto (-0500)
    
    time: 23:00:00
    date: 2021-12-04
    location: Berlin (Germany)
    zone: Europe/Berlin (+0100)
    

    Behaviour for "12pm" — program panics:

    $ when "12pm in montreal -> berlin"
    thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/parser.rs:68:22
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    

    Behaviour for "12am" — program treats it as 12:00 (which AFAIK is 12pm):

    $ when "12am in montreal -> berlin"
    time: 12:00:00
    date: 2021-12-04
    location: Montreal (Canada)
    zone: America/Toronto (-0500)
    
    time: 18:00:00
    date: 2021-12-04
    location: Berlin (Germany)
    zone: Europe/Berlin (+0100)
    
    opened by kytta 0
Owner
Armin Ronacher
Software developer and Open Source nut. Creator of the Flask framework. Engineering at @getsentry. Other things of interest: @pallets and @rust-lang
Armin Ronacher
Small command-line tool to switch monitor inputs from command line

swmon Small command-line tool to switch monitor inputs from command line Installation git clone https://github.com/cr1901/swmon cargo install --path .

William D. Jones 5 Aug 20, 2022
Command-line HTTP client for sending a POST request to specified URI on each stdin line.

line2httppost Simple tool to read lines from stdin and post each line as separate POST request to a specified URL (TCP connection is reused though). G

Vitaly Shukela 3 Jan 3, 2023
Pink is a command-line tool inspired by the Unix man command.

Pink is a command-line tool inspired by the Unix man command. It displays custom-formatted text pages in the terminal using a subset of HTML-like tags.

null 3 Nov 2, 2023
Checkline: checkbox line picker for stdin line input

checkline is a Unix command line interface (CLI) terminal user interface (TUI) that prompts you to check each line of stdin, to pick each line to output to stdout

SixArm 4 Dec 4, 2022
A full featured, fast Command Line Argument Parser for Rust

clap Command Line Argument Parser for Rust It is a simple-to-use, efficient, and full-featured library for parsing command line arguments and subcomma

null 10.4k Jan 10, 2023
Docopt for Rust (command line argument parser).

THIS CRATE IS UNMAINTAINED This crate is unlikely to see significant future evolution. The primary reason to choose this crate for a new project is if

null 743 Jan 1, 2023
Parse command line arguments by defining a struct.

StructOpt Parse command line arguments by defining a struct. It combines clap with custom derive. Documentation Find it on Docs.rs. You can also check

Guillaume P. 2.6k Jan 5, 2023
A command line progress reporting library for Rust

indicatif Documentation A Rust library for indicating progress in command line applications to users. This currently primarily provides progress bars

Armin Ronacher 3.2k Dec 30, 2022
Low-level Rust library for implementing terminal command line interface, like in embedded systems.

Terminal CLI Need to build an interactive command prompt, with commands, properties and with full autocomplete? This is for you. Example, output only

HashMismatch 47 Nov 25, 2022
⚡️ Lightning-fast and minimal calendar command line. Written in Rust 🦀

⚡️ Lightning-fast and minimal calendar command line. It's similar to cal. Written in Rust ??

Arthur Henrique 36 Jan 1, 2023
Command-Line program that takes images and produces the copy of the image with a thin frame and palette made of the 10 most frequent colors.

paleatra v.0.0.1 Command-Line program that takes an image and produces the copy of the image with a thin frame and palette made of the 10 most frequen

Beka Modebadze 24 Dec 29, 2022
parse command-line arguments into a hashmap and vec of positional args

parse command-line arguments into a hashmap and vec of positional args This library doesn't populate custom structs, format help messages, or convert types.

James Halliday 17 Aug 11, 2022
A tactics trainer for the command line

Chess Tactics CLI Practice some chess tactics in your terminal while you wait for your code to compile. Fetches tactics from this tactics API. Built W

Marcus Buffett 28 Dec 21, 2022
Cork is a simple command-line calculator, mainly targeted towards people who deal with hex numbers

Cork is a simple command-line calculator, mainly targeted towards people who deal with hex numbers. It deals only with integer arithmetic. Expressions may involve mixed bases (limited to decimal, hexadecimal, octal and binary numbers). The global output format may be set to a particular radix - by default it is hex.

Deep Majumder 50 Dec 22, 2022
A small command-line application to view images from the terminal written in Rust.

A small command-line application to view images from the terminal written in Rust. It is basically the front-end of viuer

Atanas Yankov 1.9k Jan 3, 2023
belt is a command line app that can show your time from a list of selected time zones

A CLI app to show your time from a list of selected time zones, and a rust lib to parse dates in string formats that are commonly used.

Rollie Ma 23 Nov 4, 2022
rip is a command-line deletion tool focused on safety, ergonomics, and performance

rip (Rm ImProved) rip is a command-line deletion tool focused on safety, ergonomics, and performance. It favors a simple interface, and does not imple

Kevin Liu 776 Jan 1, 2023
A command-line benchmarking tool

hyperfine 中文 A command-line benchmarking tool. Demo: Benchmarking fd and find: Features Statistical analysis across multiple runs. Support for arbitra

David Peter 14.1k Jan 4, 2023
An interactive cheatsheet tool for the command-line

navi An interactive cheatsheet tool for the command-line. navi allows you to browse through cheatsheets (that you may write yourself or download from

Denis Isidoro 12.2k Dec 30, 2022