Skip to main content

Parse and format timedelta

Project description

timedeltafmt

A tool to parse and format timedelta

Examples

from datetime import timedelta

from timedeltafmt import parse_timedelta, format_timedelta, make_formatter, MICROSECOND, SECOND

print(parse_timedelta('1day 24h'))  # 2 days, 0:00:00
print(parse_timedelta('10s 1m 1s'))  # 0:01:11

print(format_timedelta(timedelta(weeks=1)))  # 7d
print(format_timedelta(timedelta(days=365.25)))  # 1y

JIFFY_FMT = make_formatter({
    MICROSECOND: 'ms',
    SECOND // 50: 'jiffies',
})

print(JIFFY_FMT.format(timedelta(seconds=2)))  # 100jiffies

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

timedeltafmt-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

timedeltafmt-0.1.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file timedeltafmt-0.1.1.tar.gz.

File metadata

  • Download URL: timedeltafmt-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for timedeltafmt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cf475f1969d3c4ee722671319e4c548bc556de5512da505facc5953ec6d54a17
MD5 f7452dee40e33be5ef143bdeafe99bde
BLAKE2b-256 cd669c5c2130149b763b82c1713f0264becde979353dad055a4cb2782311afcc

See more details on using hashes here.

File details

Details for the file timedeltafmt-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: timedeltafmt-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for timedeltafmt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 28ce0fce44748fe3c4db301c078ecc6583367540f6f5e4c41c20e64109cd7fc8
MD5 bd16062beecb330b7d8b0bb74a0edcc9
BLAKE2b-256 6a9611aac8a167950dd9a24a53366ea3c64f54e4d38cb80ebc35ee4f8fed3b37

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