diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-08-02 19:53:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-02 19:53:16 +0200 |
| commit | 9b9c805cedb08621bd5dc58a01a6478eb7cc49a9 (patch) | |
| tree | d819686fbe32fecf4b7c73030f4b7b2f24990adc /django/utils | |
| parent | 7cd187a5ba58d7769039f487faeb9a5a2ff05540 (diff) | |
Removed unneeded escapes in regexes.
Special characters lose their special meaning inside sets of characters.
"-" lose its special meaning if it's placed as the first or last
character.
Follow up to 7c6b66383da5f9a67142334cd2ed2d769739e8f1.
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/dateparse.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py index 08651f57ad..5cedd1affa 100644 --- a/django/utils/dateparse.py +++ b/django/utils/dateparse.py @@ -14,13 +14,13 @@ date_re = _lazy_re_compile(r"(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2}) time_re = _lazy_re_compile( r"(?P<hour>\d{1,2}):(?P<minute>\d{1,2})" - r"(?::(?P<second>\d{1,2})(?:[\.,](?P<microsecond>\d{1,6})\d{0,6})?)?$" + r"(?::(?P<second>\d{1,2})(?:[.,](?P<microsecond>\d{1,6})\d{0,6})?)?$" ) datetime_re = _lazy_re_compile( r"(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})" r"[T ](?P<hour>\d{1,2}):(?P<minute>\d{1,2})" - r"(?::(?P<second>\d{1,2})(?:[\.,](?P<microsecond>\d{1,6})\d{0,6})?)?" + r"(?::(?P<second>\d{1,2})(?:[.,](?P<microsecond>\d{1,6})\d{0,6})?)?" r"\s*(?P<tzinfo>Z|[+-]\d{2}(?::?\d{2})?)?$" ) @@ -31,7 +31,7 @@ standard_duration_re = _lazy_re_compile( r"((?:(?P<hours>\d+):)(?=\d+:\d+))?" r"(?:(?P<minutes>\d+):)?" r"(?P<seconds>\d+)" - r"(?:[\.,](?P<microseconds>\d{1,6})\d{0,6})?" + r"(?:[.,](?P<microseconds>\d{1,6})\d{0,6})?" r"$" ) @@ -40,11 +40,11 @@ standard_duration_re = _lazy_re_compile( iso8601_duration_re = _lazy_re_compile( r"^(?P<sign>[-+]?)" r"P" - r"(?:(?P<days>\d+([\.,]\d+)?)D)?" + r"(?:(?P<days>\d+([.,]\d+)?)D)?" r"(?:T" - r"(?:(?P<hours>\d+([\.,]\d+)?)H)?" - r"(?:(?P<minutes>\d+([\.,]\d+)?)M)?" - r"(?:(?P<seconds>\d+([\.,]\d+)?)S)?" + r"(?:(?P<hours>\d+([.,]\d+)?)H)?" + r"(?:(?P<minutes>\d+([.,]\d+)?)M)?" + r"(?:(?P<seconds>\d+([.,]\d+)?)S)?" r")?" r"$" ) |
