Go to file
2019-03-13 15:28:05 -07:00
.gitignore Initial commit 2019-03-13 15:02:54 -07:00
README.md Added format and updated README 2019-03-13 15:21:33 -07:00
requrements.txt Initial commit 2019-03-13 15:02:54 -07:00
tz.py erroring out on stderr 2019-03-13 15:28:05 -07:00

Time when and where

Find time now, in the past or future in any timezone or location.

Usage

python tz.py HUMAN_TIME [HUMAN_TZ_LOC] [--format="%Y-%m-%d %H:%M:%S%z"]
  • HUMAN_TIME - is any time or time-like string. See the dateparser for example 10:15, now, in 3 hours and many others.
  • HUMAN_TZ_LOC - (optional) is either timezone to which the date should be translated (fast) or a location (slow - and requires internet connection to resolve the location). Uses geopy for location resolution and timezonefinder for timezone resolution.
  • --format is the format of the time to be displayed. See supported datetime formats

You could alias the whole command to tww for faster typing, e.g. in your .bashrc:

alias tww="~/workspace/tz/venv/bin/python ~/workspace/tz/tz.py"

If HUMAN_TIME and/or HUMAN_TZ_LOC have spaces, they need to be quoted, e.g.:

tww "in 2 hours" "los angeles"

Install

virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt

Examples

Without timezone/location:

$ tww now
2019-03-13 15:04:36.607080

Time now in another timezone

$ tww now CET
2019-03-13 23:07:54.957743

One hour from now in UTC, showing only the time:

$ tww "in 1 hour" utc --format="%T"
23:17:49

With timezone:

$ tww now Asia/Tokyo
2019-03-14 07:06:35.273192

Another time in timezone:

$ tww 15:10 cet
2019-03-13 23:10:00

Time in location (slow!):

$ tww "3/14 15 9:26:53 PST" sofia
2015-03-14 19:26:53+02:00