Skip to content

Instantly share code, notes, and snippets.

@dimaqq
Created December 10, 2022 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimaqq/ade618104d2c5255c3220028766d73e7 to your computer and use it in GitHub Desktop.
Save dimaqq/ade618104d2c5255c3220028766d73e7 to your computer and use it in GitHub Desktop.
"""Proposal Temporal Duration in Python"""
ISO_8601_PERIOD = re.compile(
r"""
^
((?P<sign>-)|[+])?
P
((?P<years>\d+)Y)?
((?P<months>\d+)M)?
((?P<weeks>\d+)W)?
((?P<days>\d+)D)?
(T
((?P<hours>\d+)H)?
((?P<minutes>\d+)M)?
((?P<seconds>\d+)
([.](?P<subsecond>\d+))?
S)?
)?
$
""",
re.X,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment