Skip to content

Command-line tool to look up the local time (and weather) for time zones, countries and cities with auto-completion.

Notifications You must be signed in to change notification settings

jschuur/localtime-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Local time and weather command line tool

Command-line tool to look up the local time (and weather) for time zones, countries and cities with auto-completion.

Animated GIF of localtime shell CLI, showing the city of London being typed in and picked from a list, then local time and weather results appear.

My partner (:heart: :frog:) was out of town, and I wanted a quick way to see her local time and weather. Fun little project to start using TypeScript too.

Usage

Install as a global localtime command:

npm install -g localtime-cli

Or run ad hoc:

npx localtime-cli

Options

Show full options with localtime --help

  • -t --timezone use timezone names for search (default: true)
  • --no-timezone don't use timezone names
  • -c --country use country names
  • -y --city use city names with a population >= 250,000
  • -Y --city-all use all city names
  • -a --all-min, use all location types (with minimum city population)
  • -A --all use all location types (no city population minimum)
  • -w --weather include local weather
  • -o --openweather-api-key <key> specify OpenWeather API key
  • -O --save-openweather-api-key <key> specify and save OpenWeather API key for future use
  • -l --last bypass location search and reuse last location used
  • -C --metric, use metric units (celsius)
  • -F --imperial, use imperial units (fahrenheit)

Thus localtime -c -y would search time zone, country and larger city names and localtime --no-timezone -Y would search just through all city names, since time zones are always used unless explicitly excluded.

Multiple single letter options can be combined too: localtime -cy.

The last previously used location will be sorted to the top of the list unless --skip-last-used-sort is used.

Weather

Weather info works for city selections and requires a free OpenWeather API key provided via the -o option to use it once or -O to save it for future use without needing to provide it as an option again.

Example:

localtime -y -w -O abc123

In subsequent uses, you can then just run localtime -y -w.

You can also set it via the OPENWEATHER_API_KEY environment variable.

Initially, the metric system will be used and weather temperatures will be in celsius. Subsequent invocations will reuse the previously specified unit of measurement, unless a new one is selected via command line options.

- Joost Schuur (@joostschuur)

About

Command-line tool to look up the local time (and weather) for time zones, countries and cities with auto-completion.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published