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.1.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: when-3.1.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.13

File hashes

Hashes for when-3.1.0.tar.gz
Algorithm Hash digest
SHA256 a341414f7541c4ee8a713722a3bb5ae53b509243c02ff126f91915106f71b316
MD5 30cfd8febd5d6c4a14b1b18ee469ea84
BLAKE2b-256 8bd0dbc2a96636e71797156409a4e67d6d348518ea1623f1d50d97d7b7aaf64b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: when-3.1.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.13

File hashes

Hashes for when-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3fc4a90238487a756b39a10f1ebe2aa21990b177cf0b3329cc2b8937936fc281
MD5 0a08e90bb919b062187d0850777e4978
BLAKE2b-256 b8020e5e1517712e9075ca95cee1b63d1a125b499e0f035b9369bb34d1c8f075

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