Skip to main content

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


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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jetblack_iso8601-1.0.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file jetblack-iso8601-1.0.0.tar.gz.

File metadata

  • Download URL: jetblack-iso8601-1.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.10 Linux/5.4.0-81-generic

File hashes

Hashes for jetblack-iso8601-1.0.0.tar.gz
Algorithm Hash digest
SHA256 aadb526ad0a25e36222b947370ec07659e2ab7ad07e5186c29afe724072c5e25
MD5 e0c1b62c2af38cb62d6301236c631b6d
BLAKE2b-256 7e68cbcbcbc3f8cd839fec681138de45a03aca310c4db410071fcf84d8967ec0

See more details on using hashes here.

File details

Details for the file jetblack_iso8601-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: jetblack_iso8601-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.10 Linux/5.4.0-81-generic

File hashes

Hashes for jetblack_iso8601-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1be383e9b04e924fe50cb254ad75661bb38250750fe7b6b55a76a03daa9ee82
MD5 1e48db8de274a37017a3b86194c25d86
BLAKE2b-256 158aa0010942aa68a02f00339e92b2876b99402520dc2c5dff16756d43de9a40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page