ISO 8601 support
Project description
jetblack-iso8601
Support for ISO8601 (read the docs).
Usage
Timestamps
Timestamps can be parsed with iso8601_to_datetime
and
converted to a string with datetime_to_iso8601
.
from jetblack_iso8601 import (
iso8601_to_datetime,
datetime_to_iso8601
)
text = '2014-02-01T09:28:56.321-10:00'
timestamp = iso8601_to_datetime(text)
roundtrip = datetime_to_iso8601(timestamp)
assert text == roundtrip
Durations
Timestamps can be parsed with iso8601_to_timedelta
and
converted to a string with datetime_to_iso8601
.
from jetblack_iso8601 import (
iso8601_to_timedelta,
timedelta_to_iso8601
)
text = 'P3Y2M1DT12H11M10S'
value = iso8601_to_timedelta(text)
roundtrip = timedelta_to_iso8601(value)
assert roundtrip == text
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
jetblack-iso8601-1.0.1.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for jetblack_iso8601-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87ce1981c7afb50baa7492c649555045e536558b23b99911361898a0780962fe |
|
MD5 | f19c06ae8ff1fe1505f1e1b25c8d2159 |
|
BLAKE2b-256 | 96a402705b70ea9d457e8cdbc99773079e1dddc570b097c5a2dfd9f0ebfeee03 |