Skip to main content

Calculate and convert times across time zones and cities of significant population.

Project description

https://github.com/dakrauth/when/actions/workflows/test.yml/badge.svg

Installation

Install from PyPI:

$ pip install when

or using pipx:

$ pipx install when

or:

$ pipx install git+https://github.com/dakrauth/when.git

Usage

To access city names, you must install the cities database:

when --db

You can specify minimum city size by adding --size SIZE, where SIZE can be one of:

  • 15000 - cities with population > 15000 or capitals

  • 5000 - cities with population > 5000 or seat of first-order admin division, i.e. US state

  • 1000 - cities with population > 1000 or seat of third order admin division

  • 500 - cities with population > 500 or seat of fourth-order admin division

Additionally, you can filter non-admin division seats using --pop POP.

The appropriate GeoNames Gazetteer is downloaded and a Sqlite database generated. Once installed, you can search the database:

$ when --db --search New York
5106292, West New York, West New York, US, New Jersey, America/New_York
5128581, New York City, New York City, US, New York, America/New_York

Additionally, you can add aliases. In the example directly above, we see that New York City has a GeoNames ID of 5128581. Pass that to the --alias option along with another name that you would like to use:

$ when --db --alias 5128581 NYC
$ when --source NYC
2023-07-06 07:58:33-0400 (EDT, America/New_York) 187d27w (New York City, New York, US)[🌕 Full Moon]

Example

$ when
2023-07-06 20:58:02+0900 (KST, Asia/Seoul) 187d27w [🌕 Full Moon]

$ when --source CST
2023-07-06 06:58:54-0500 (CDT, Central Standard Time) 187d27w [🌕 Full Moon]
2023-07-06 15:58:54+0400 (+04, Caucasus Standard Time) 187d27w [🌕 Full Moon]
2023-07-06 19:58:54+0800 (CST, China Standard Time) 187d27w [🌕 Full Moon]
2023-07-06 07:58:54-0400 (CDT, Cuba Standard Time) 187d27w [🌕 Full Moon]

$ when --source Paris
2023-07-06 13:59:25+0200 (CEST, Europe/Paris) 187d27w (Villeparisis, Île-de-France, FR)[🌕 Full Moon]
2023-07-06 13:59:25+0200 (CEST, Europe/Paris) 187d27w (Paris, Île-de-France, FR)[🌕 Full Moon]
2023-07-06 13:59:25+0200 (CEST, Europe/Paris) 187d27w (Cormeilles-en-Parisis, Île-de-France, FR)[🌕 Full Moon]
2023-07-06 07:59:25-0400 (EDT, America/Port-au-Prince) 187d27w (Fond Parisien, Ouest, HT)[🌕 Full Moon]
2023-07-06 06:59:25-0500 (CDT, America/Chicago) 187d27w (Paris, Texas, US)[🌕 Full Moon]

$ when --source "San Francisco,US" --target America/New_York Mar 7 1945 7:00pm
1945-03-07 22:00:00-0400 (EWT, America/New_York) 066d10w [🌘 Waning Crescent]
1945-03-07 22:00:00-0400 (EWT, America/New_York) 066d10w [🌘 Waning Crescent]

Develop

Requirements Python 3.8+

$ git clone git@github.com:dakrauth/when.git
$ cd when
$ python -mvenv venv
$ . venv/bin/activate
$ pip install .
$ when --help
$ when --db
$ pip install tox
$ tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

when-3.0.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

when-3.0.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file when-3.0.0.tar.gz.

File metadata

  • Download URL: when-3.0.0.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for when-3.0.0.tar.gz
Algorithm Hash digest
SHA256 44f8844b67da75dd140e2b06980e7929634706d8c706df8e172b6736ae72e409
MD5 62093b7d2e3b7664d2ddd5cdc419127e
BLAKE2b-256 fb2066b3ad078d6b3814410bb023faae0ec99b3b7e71d026f1363fb95828c26a

See more details on using hashes here.

File details

Details for the file when-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: when-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for when-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68e11a255d338569ca394d7f91ac4f57b41cca9221986d13154885998c58a4fa
MD5 7f9d0c6121e55ce14346a0d8170bc816
BLAKE2b-256 68f3eb800f8d7be8f348c1430211eaf004ad855cf56b13b29bb54551a0117a36

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page