Omega359 commented on code in PR #19078:
URL: https://github.com/apache/datafusion/pull/19078#discussion_r2627473292
##########
datafusion/functions/src/datetime/common.rs:
##########
@@ -89,11 +101,55 @@ pub(crate) fn string_to_datetime_formatted<T: TimeZone>(
)
};
+ let mut datetime_str = s;
+ let mut format = format;
+
+ // Manually handle the most common case of a named timezone at the end of
the timestamp.
+ // Note that %+ handles 'Z' at the end of the string without a space. This
code doesn't
+ // handle named timezones with no preceding space since that would require
writing a
+ // custom parser (or switching to Jiff)
+ let tz: Option<chrono_tz::Tz> = if format.ends_with(" %Z") {
+ // grab the string after the last space as the named timezone
+ if let Some((dt_str, timezone_name)) = datetime_str.rsplit_once(' ') {
Review Comment:
splitting on any ascii whitespace is easy but the .ends_with call isn't
quite so easy to do. I've updated to trim the end at least.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]