@@ -93,57 +93,57 @@ def test_extract_unit(
93
93
94
94
95
95
@pytest .mark .parametrize (
96
- "datetime_string, possible_date_formats, expected_iso8601, tzinfo " ,
96
+ "datetime_string, possible_date_formats, tzinfo, expected_iso8601 " ,
97
97
[
98
98
# Test cases with valid datetime strings and formats
99
99
(
100
100
"2023-10-23 14:30:00" ,
101
101
["%Y-%m-%d %H:%M:%S" ],
102
- "2023-10-23T14:30:00+00:00" ,
103
102
datetime .timezone .utc ,
103
+ "2023-10-23T14:30:00+00:00" ,
104
104
),
105
105
(
106
106
"23/10/2023 14:30" ,
107
107
["%d/%m/%Y %H:%M" ],
108
- "2023-10-23T14:30:00+00:00" ,
109
108
datetime .timezone .utc ,
109
+ "2023-10-23T14:30:00+00:00" ,
110
110
),
111
111
(
112
112
"October 23, 2023 14:30" ,
113
113
["%B %d, %Y %H:%M" ],
114
- "2023-10-23T14:30:00+00:00" ,
115
114
datetime .timezone .utc ,
115
+ "2023-10-23T14:30:00+00:00" ,
116
116
),
117
117
(
118
118
"2023-10-23T14:30:00Z" ,
119
119
["%Y-%m-%dT%H:%M:%SZ" ],
120
- "2023-10-23T14:30:00+00:00" ,
121
120
datetime .timezone .utc ,
121
+ "2023-10-23T14:30:00+00:00" ,
122
122
),
123
123
(
124
124
"2023-10-23T14:30:00+0200" ,
125
125
["%Y-%m-%dT%H:%M:%S%z" ],
126
- "2023-10-23T14:30:00+02:00" ,
127
126
datetime .timezone (datetime .timedelta (hours = 2 )),
127
+ "2023-10-23T14:30:00+02:00" ,
128
128
),
129
129
# Test cases with timezone information
130
130
(
131
131
"2023-10-23 14:30:00" ,
132
132
["%Y-%m-%d %H:%M:%S" ],
133
- "2023-10-23T14:30:00+00:00" ,
134
133
datetime .timezone (datetime .timedelta (hours = 1 )),
134
+ "2023-10-23T14:30:00+01:00" ,
135
135
),
136
136
# Test case with missing timezone should still return UTC
137
137
(
138
138
"2023-10-23 14:30:00" ,
139
139
["%Y-%m-%d %H:%M:%S" ],
140
- "2023-10-23T14:30:00+00:00" ,
141
140
None ,
141
+ "2023-10-23T14:30:00" ,
142
142
),
143
143
],
144
144
)
145
145
def test_parse_datetime (
146
- datetime_string , possible_date_formats , expected_iso8601 , tzinfo
146
+ datetime_string , possible_date_formats , tzinfo , expected_iso8601
147
147
):
148
148
result = parse_datetime (datetime_string , possible_date_formats , tzinfo )
149
149
assert result == expected_iso8601 , f"Expected { expected_iso8601 } but got { result } "
0 commit comments