Chronos
Simple and easy to use time-related utility functions.
These are simple routines we caught ourselves constantly in need when developing projects in Hackt. They're all a combination of native Python libraries that we wanted to standardize in a standlone library.
Usage
Install from PyPI:
pip install python_chronos
Import in your project(s):
import chronos
Get current UTC timestamp (datetime type)
chronos.utc_now()
# datetime.datetime(2021, 2, 2, 3, 59, 11, 856368)
UTC timestamp (integer type)
chronos.utc_timestamp()
# 1612238428
Past/Future UTC (datetime type)
The following function adds 10 minutes to the current UTC datetime:
chronos.future_utc_datetime(minutes=10)
# datetime.datetime(2021, 2, 2, 4, 14, 3, 573054)
Similarly, the past_utc_datetime function does exactly what you have in mind:
chronos.past_utc_datetime(minutes=10)
# datetime.datetime(2021, 2, 2, 3, 54, 3, 573054)
Any keyword arguments you would pass to datetime.timedelta will work with future_utc_datetime and past_utc_datetime.
Past/Future UTC in UNIX timestamp (integer type)
chronos.future_utc_timestamp(hours=2)
# 1612246043
Analogously, the past_utc_timestamp function will do exactly what you expect:
chronos.past_utc_timestamp(hours=2)
# 1612238843
Again, any keyword arguments you would pass to datetime.timedelta will work with future_utc_timestamp and past_utc_timestamp.
Metadata
Release files for python-chronos 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_chronos-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for python_chronos-0.2.0-py3-none-any.whl |
Release files / python_chronos-0.2.0-py3-none-any.whl
| Download URL | python_chronos-0.2.0-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
625f52f34628c56b190ac9480c3c010cdd97624b567aeae869a4e22e3db32652
|
|
BLAKE2b-256 checksum How to use checksums |
00c157dba9453ce0c4897de0c0f6bee5e6f5f7ba7427d0b04339d27ba0b32cee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.2
|
Security for python-chronos 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.