From 1199780155f666b6806d563a29d093a251664009 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 30 Jan 2021 09:13:47 +0100 Subject: Adding upstream version 2.1.2. Signed-off-by: Daniel Baumann --- pendulum/parsing/iso8601.py | 447 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 447 insertions(+) create mode 100644 pendulum/parsing/iso8601.py (limited to 'pendulum/parsing/iso8601.py') diff --git a/pendulum/parsing/iso8601.py b/pendulum/parsing/iso8601.py new file mode 100644 index 0000000..40efa2f --- /dev/null +++ b/pendulum/parsing/iso8601.py @@ -0,0 +1,447 @@ +from __future__ import division + +import datetime +import re + +from ..constants import HOURS_PER_DAY +from ..constants import MINUTES_PER_HOUR +from ..constants import MONTHS_OFFSETS +from ..constants import SECONDS_PER_MINUTE +from ..duration import Duration +from ..helpers import days_in_year +from ..helpers import is_leap +from ..helpers import is_long_year +from ..helpers import week_day +from ..tz.timezone import UTC +from ..tz.timezone import FixedTimezone +from .exceptions import ParserError + + +ISO8601_DT = re.compile( + # Date (optional) + "^" + "(?P" + " (?P" # Classic date (YYYY-MM-DD) or ordinal (YYYY-DDD) + r" (?P\d{4})" # Year + " (?P" + r" (?P-)?(?P\d{2})" # Month (optional) + r" ((?P-)?(?P\d{1,2}))?" # Day (optional) + " )?" + " )" + " |" + " (?P" # Calendar date (2016-W05 or 2016-W05-5) + r" (?P\d{4})" # Year + " (?P-)?" # Separator (optional) + " W" # W separator + r" (?P\d{2})" # Week number + " (?P-)?" # Separator (optional) + r" (?P\d)?" # Weekday (optional) + " )" + ")?" + # Time (optional) + "(?P