pytimelib is a simple model for python to do time conversion.
Project description
pytimelib
- pytimelib is a simple model for python to do time conversion.
- python 3
- It is base on arrow library and pytz libraty, making it easy to use aware time and native time conversion.
Installation
From PyPi:
$ pip install pytimelib
Basic Usage
-
cover datetime to timestamp:
import time import datetime from pytimelib import TimeLib date_time = datetime.datetime.now() timestamp = TimeLib.datetime_to_timestamp(date_time) date_time = TimeLib.timestamp_to_datetime(timestamp)
-
datetime to timestamp conversion by timezone:
for example:
import time import datetime from pytimelib import TimeLib date_time = datetime.datetime.utcnow() print("datetime to timestamp by timezone(from UTC):") timestamp = TimeLib.datetime_to_timestamp_by_timezone(date_time, from_tz="UTC") print(timestamp) print("timestamp to datetime by timezone(UTC to Los Angeles):") date_time = TimeLib.timestamp_to_datetime_by_timezone( timestamp, to_tz="America/Los_Angeles") print(date_time)
-
datetime and timeString conversion by timezone:
for example:
import time import datetime from pytimelib import TimeLib # datetime and timeString by timezone print("datetime to timeString by timezone(UTC to Los Angeles):") date_time = datetime.datetime.utcnow() time_str = TimeLib.datetime_to_datetime_str_by_timezone(date_time, to_tz="America/Los_Angeles") print(time_str) print("timeString to datetime by timezone(Los Angeles to UTC):") date_time = TimeLib.datetime_str_to_datetime_by_timezone( time_str, from_tz="America/Los_Angeles", to_tz="UTC") print(date_time)
Learning more
Check the documentation for more examples or read test cases in unit test code.
Change Log
Discussing
- submit issue
- email: henry_czh@foxmail.com
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
pytimelib-1.0.2.tar.gz
(4.0 kB
view details)
File details
Details for the file pytimelib-1.0.2.tar.gz.
File metadata
- Download URL: pytimelib-1.0.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64aee408ce0dd0dbff9889776e6effbb74e38d24ac8e85ceda9e328a03e21164
|
|
| MD5 |
e054bc7499403de1800d7e0b5f78e7d2
|
|
| BLAKE2b-256 |
1b8fe73f3a9c27c733ab00dbafaa577abe8c8df567058f9806a958c0a3eb7496
|