Skip to content

Commit

Permalink
date string coerced to datetime shouldn't infer timezone (#1193)
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-runkle authored Feb 15, 2024
1 parent fadeecc commit 61a6562
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/validators/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ impl Validator for DateTimeValidator {
}

/// 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.
///
/// Ok(None) means that this is not relevant to datetimes (the input was not a date nor a string)
fn datetime_from_date<'data>(input: &'data impl Input<'data>) -> Result<Option<EitherDateTime<'data>>, ValError> {
let either_date = match input.validate_date(false) {
Expand Down Expand Up @@ -171,7 +170,7 @@ fn datetime_from_date<'data>(input: &'data impl Input<'data>) -> Result<Option<E
minute: 0,
second: 0,
microsecond: 0,
tz_offset: Some(0),
tz_offset: None,
};

let datetime = DateTime {
Expand Down
2 changes: 1 addition & 1 deletion tests/validators/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[
(datetime(2022, 6, 8, 12, 13, 14), datetime(2022, 6, 8, 12, 13, 14)),
(date(2022, 6, 8), datetime(2022, 6, 8)),
('2022-01-01', datetime(2022, 1, 1, 0, 0, 0, tzinfo=timezone.utc)),
('2022-01-01', datetime(2022, 1, 1, 0, 0, 0)),
('2022-06-08T12:13:14', datetime(2022, 6, 8, 12, 13, 14)),
('1000000000000', datetime(2001, 9, 9, 1, 46, 40, tzinfo=timezone.utc)),
(b'2022-06-08T12:13:14', datetime(2022, 6, 8, 12, 13, 14)),
Expand Down

0 comments on commit 61a6562

Please sign in to comment.