Provides methods to manipulate and format various time-based objects into human-readable strings.
Project description
Time Formatting Tools
Provides methods to manipulate and format various time-based objects into human-readable strings.
Usage
import datetime
import timefmt
now = datetime.datetime.now()
print("Now (short):", timefmt.dt.short(now))
print("Now (long):", timefmt.dt.long(now))
since_epoch = datetime.timedelta(seconds=now.timestamp())
print("Time since Jan. 1st, 1970 (short):", timefmt.td.short(since_epoch))
print("Time since Jan. 1st, 1970 (long):", timefmt.td.long(since_epoch))
# You can also automatically detect which type it is, like so
import random
random_choice = random.choice([now, since_epoch])
print("Unknown time format value (short):", timefmt.auto(random_choice))
print("Unknown time format value (long):", timefmt.auto(random_choice, long=True))
This prints the following:
Now (short): 11:12:12 AM
Now (long): 11:12:12 AM US Mountain Standard Time
Time since Jan. 1st, 1970 (short): 2817W 2D 18:12:12
Time since Jan. 1st, 1970 (long): 2817 weeks, 2 days, 18 hours, 12 minutes, and 12 seconds
Unknown time format value (short): 11:12:12 AM
Unknown time format value (long): 11:12:12 AM US Mountain Standard Time
Full Documentation
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
timefmt-0.2.2.tar.gz
(15.6 kB
view details)
Built Distributions
timefmt-0.2.2-py3-none-any.whl
(17.2 kB
view details)
File details
Details for the file timefmt-0.2.2.tar.gz
.
File metadata
- Download URL: timefmt-0.2.2.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4bcc278f6b07c6da6e10e913c5ae98e93df8119a645fef33204277585151e6f |
|
MD5 | 721fd15bf48b27e6bea4a74f62309d49 |
|
BLAKE2b-256 | ed95e44fba1006c08caf0005432967bf4ecbde0877f0c9b75f1644fa2ae692c4 |
File details
Details for the file timefmt-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: timefmt-0.2.2-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb6b468b9ff026c8ac77541d454592e688a6800a45691eb66d8b9fffc8cb72bb |
|
MD5 | daf784bc0328fec44f7910314f12382e |
|
BLAKE2b-256 | 884242c4f73311124248c11b2a92b0e666b44c314baca07b68e5f8b2d708390d |
File details
Details for the file timefmt-0.2.2-py2.py3-none-any.whl
.
File metadata
- Download URL: timefmt-0.2.2-py2.py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2b1edd9beb63a011413db5959680f3b4ec239bff8b73855578304575a396b6d |
|
MD5 | 212cf1628cbb3c60a896951ff94e32ac |
|
BLAKE2b-256 | f3bf01be909c5038da4e7d052080543efcdc4fdb2e4aada15cec22809177ab70 |