Skip to main content

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

timeformat on Read the Docs

Project details


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.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

timefmt-0.2.0-py2.py3-none-any.whl (17.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file timefmt-0.2.0.tar.gz.

File metadata

  • Download URL: timefmt-0.2.0.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

Hashes for timefmt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5b61535ad4972f0c70101316d407b2a2da62bc3e49aa3cfbcf0b328aa3d515c7
MD5 6cac543cfc728cad1bd2fc3836336933
BLAKE2b-256 f0bd3fcd2dda4d3849ee5ee2cbd48c59153acebc07821ccdc86c787b90fc65e7

See more details on using hashes here.

File details

Details for the file timefmt-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: timefmt-0.2.0-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

Hashes for timefmt-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a963f42e985269b34b206f162103577828768dbe0a8d63e6d82c0f660b5a6335
MD5 84ff68f3f7336c475cede1670536127a
BLAKE2b-256 14c2e77968c0b159f3042b2679066f4de499fdccb190e2d60b56f55b6b52bf81

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page