File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -826,7 +826,22 @@ def format_is_iso(f: str) -> bint:
826
826
"""
827
827
iso_regex = \
828
828
r"^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(([+-]\d{2}:\d{2})|Z )?)?)?)?$"
829
+
830
+ # ^ -> matches the start of the string
831
+ # \d{4} -> matches the four digit(0-9) which represent the year
832
+ # -\d{2} -> matches the dash followed by 2 digits
833
+ # T\d{2}:\d{2}:\d{2} \
834
+ -> "T" followed by three groups seperated by colon: represent H:M:S
835
+ # (\.\d+)? -> represents the fractions of seconds
836
+ # (([+-]\d{2}:\d{2})|Z )? -> optional part match the time zone info
837
+ # ? -> The ? at the end makes the part of regex optional
838
+ # $ -> matches with the end
839
+
829
840
excluded_formats = [" %Y%m%d " , " %Y%m " , " %Y " ]
841
+
842
+ # uses the 're' module to check if the string matches the regular
843
+ # expression and not in the list of 'excluded_formats' then it will return true
844
+
830
845
if re.match(iso_regex , f ) and f not in excluded_formats:
831
846
return True
832
847
return False
You can’t perform that action at this time.
0 commit comments