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

Uploaded Source

Built Distribution

timefmt-0.1.0-py2.py3-none-any.whl (17.3 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: timefmt-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for timefmt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c05d286f44a99aa3ea10ccca4ab49e2fb851beb9ae0ac2b6df93c2583444b47
MD5 4f3bb3cc7eb3da1d0f3ce47e3fc9b30f
BLAKE2b-256 8f99b5f6aea60713c5ef6dd2e1c407579f4eef8bb19857887d8d3fbe417b9b45

See more details on using hashes here.

File details

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

File metadata

  • Download URL: timefmt-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for timefmt-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 77137313a1725e36311c49f7738fcd45ab7784818439e9a1c5ffaa7f113a1751
MD5 47d2c9559a171f3af6045c3a437bfd8f
BLAKE2b-256 00aeb4fcc59296557325e07b5c2870b5b0eedec1d24fc6b7db1166d3fef029a3

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