pub fn try_localize_datetime(
ndt: NaiveDateTime,
tz: &Tz,
ambiguous: Ambiguous,
non_existent: NonExistent,
) -> Result<Option<NaiveDateTime>, PolarsError>Available on crate feature
timezones and (crate features dtype-date or dtype-datetime or temporal) only.Expand description
Localize datetime according to given time zone.
e.g. ‘2021-01-01 03:00’ -> ‘2021-01-01 03:00CDT’
Note: this may only return Ok(None) if ambiguous is Ambiguous::Null
or if non_existent is NonExistent::Null.
Otherwise, it will either return Ok(Some(NaiveDateTime)) or PolarsError.
Therefore, calling try_localize_datetime(..., Ambiguous::Raise, NonExistent::Raise)?.unwrap()
is safe, and will never panic.