https://github.com/rob-blackbourn/jetblack-iso8601
ISO 8601 support for parsing and printing
https://github.com/rob-blackbourn/jetblack-iso8601
iso8601
Last synced: 4 months ago
JSON representation
ISO 8601 support for parsing and printing
- Host: GitHub
- URL: https://github.com/rob-blackbourn/jetblack-iso8601
- Owner: rob-blackbourn
- License: apache-2.0
- Created: 2021-08-26T13:47:13.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-05-08T16:20:42.000Z (5 months ago)
- Last Synced: 2025-06-09T11:15:18.884Z (4 months ago)
- Topics: iso8601
- Language: Python
- Homepage: https://rob-blackbourn.github.io/jetblack-iso8601/
- Size: 1.12 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jetblack-iso8601
Support for ISO8601
(read the [docs](https://rob-blackbourn.github.io/jetblack-iso8601/)).## Usage
### Timestamps
Timestamps can be parsed with `iso8601_to_datetime` and
converted to a string with `datetime_to_iso8601`.```python
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`.```python
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
```