Skip to content

Commit 33f5d8f

Browse files
committed
date string coerced to datetime shouldn't infer timezone (#1193)
1 parent 305a837 commit 33f5d8f

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/validators/datetime.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ impl Validator for DateTimeValidator {
140140
}
141141

142142
/// In lax mode, if the input is not a datetime, we try parsing the input as a date and add the "00:00:00" time.
143-
///
144143
/// Ok(None) means that this is not relevant to datetimes (the input was not a date nor a string)
145144
fn datetime_from_date<'data>(input: &'data impl Input<'data>) -> Result<Option<EitherDateTime<'data>>, ValError> {
146145
let either_date = match input.validate_date(false) {
@@ -171,7 +170,7 @@ fn datetime_from_date<'data>(input: &'data impl Input<'data>) -> Result<Option<E
171170
minute: 0,
172171
second: 0,
173172
microsecond: 0,
174-
tz_offset: Some(0),
173+
tz_offset: None,
175174
};
176175

177176
let datetime = DateTime {

tests/validators/test_datetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[
2020
(datetime(2022, 6, 8, 12, 13, 14), datetime(2022, 6, 8, 12, 13, 14)),
2121
(date(2022, 6, 8), datetime(2022, 6, 8)),
22-
('2022-01-01', datetime(2022, 1, 1, 0, 0, 0, tzinfo=timezone.utc)),
22+
('2022-01-01', datetime(2022, 1, 1, 0, 0, 0)),
2323
('2022-06-08T12:13:14', datetime(2022, 6, 8, 12, 13, 14)),
2424
('1000000000000', datetime(2001, 9, 9, 1, 46, 40, tzinfo=timezone.utc)),
2525
(b'2022-06-08T12:13:14', datetime(2022, 6, 8, 12, 13, 14)),

0 commit comments

Comments
 (0)