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
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
timedeltafmt-0.1.1.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for timedeltafmt-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28ce0fce44748fe3c4db301c078ecc6583367540f6f5e4c41c20e64109cd7fc8 |
|
MD5 | bd16062beecb330b7d8b0bb74a0edcc9 |
|
BLAKE2b-256 | 6a9611aac8a167950dd9a24a53366ea3c64f54e4d38cb80ebc35ee4f8fed3b37 |