Make naive datetime objects timezone aware using city names
Project description
tzconvert
tzconvert is a simple library for converting a naive, timezone unaware datetime object to it's smarter, timezone aware version.
Installation
Installation is straightforward.
pip install tzconvert
Installing from sources
-
Clone this git repository.
-
cd into the project folder.
-
run
python setup.py install
Usage
>>> import tzconvert
>>> import datetime
>>> naive_datetime = datetime.datetime.utcnow()
>>> naive_datetime
datetime.datetime(2020, 4, 21, 22, 36, 27, 945535)
>>> adjusted_datetime = tzconvert.adjust_datetime(naive_datetime, "Venice")
>>> adjusted_datetime
datetime.datetime(2020, 4, 22, 0, 36, 27, 945535, tzinfo=tzoffset('GMT', 7200))
NOTES :
- adjust_datetime() returns
None
on failure. - adjust_datetime() takes an optional argument
debug
, set it to True to display debug messages on stdout.
PR's are more than welcome.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tzconvert-0.0.2.post1.tar.gz
(1.7 kB
view hashes)
Built Distribution
Close
Hashes for tzconvert-0.0.2.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9cd2f154791b68dbce3ae742e5c366681229f6306ca2ee68a04a16039951ff5 |
|
MD5 | d419885fbf90b6ba1c9cb90b1ccb381c |
|
BLAKE2b-256 | c39dddda115397b37e2e96c1d334b060f4ae8a5a43dbe2bfeb4ec07780892ce0 |