@@ -53,6 +53,26 @@ from pandas._libs.tslibs.timestamps import Timestamp
53
53
54
54
cnp.import_array()
55
55
56
+ cpdef bint format_is_iso(f: str ):
57
+ """
58
+ Does format match the iso8601 set that can be handled by the C parser?
59
+ Generally of form YYYY-MM-DDTHH:MM:SS - date separator can be different
60
+ but must be consistent. Leading 0s in dates and times are optional.
61
+ """
62
+ iso_template = " %Y {date_sep}%m {date_sep}%d {time_sep}%H :%M :%S {micro_or_tz}" .format
63
+ excluded_formats = [" %Y%m " ]
64
+
65
+ for date_sep in [" " , " /" , " \\ " , " -" , " ." , " " ]:
66
+ for time_sep in [" " , " T" ]:
67
+ for micro_or_tz in [" " , " %z " , " .%f " , " .%f%z " ]:
68
+ if (iso_template(date_sep = date_sep,
69
+ time_sep = time_sep,
70
+ micro_or_tz = micro_or_tz,
71
+ ).startswith(f) and f not in excluded_formats):
72
+ return True
73
+ return False
74
+
75
+
56
76
cdef bint parse_today_now(str val, int64_t* iresult, bint utc):
57
77
# We delay this check for as long as possible
58
78
# because it catches relatively rare cases
@@ -114,8 +134,6 @@ def array_strptime(
114
134
exact : matches must be exact if True, search if False
115
135
errors : string specifying error handling, {'raise', 'ignore', 'coerce'}
116
136
"""
117
- from pandas._libs.tslibs.parsing import format_is_iso
118
-
119
137
cdef:
120
138
Py_ssize_t i, n = len (values)
121
139
npy_datetimestruct dts
0 commit comments