projjal commented on code in PR #13428:
URL: https://github.com/apache/arrow/pull/13428#discussion_r924337280
##########
cpp/src/gandiva/gdv_function_stubs.cc:
##########
@@ -611,6 +611,58 @@ int32_t gdv_fn_cast_intervalyear_utf8_int32(int64_t
context_ptr, int64_t holder_
auto* holder = reinterpret_cast<gandiva::IntervalYearsHolder*>(holder_ptr);
return (*holder)(context, data, data_len, in1_validity, out_valid);
}
+
+GANDIVA_EXPORT
+gdv_timestamp to_utc_timezone_timestamp(int64_t context, gdv_timestamp
time_miliseconds,
+ const char* timezone, gdv_int32
length) {
+ using arrow_vendored::date::locate_zone;
+ using arrow_vendored::date::sys_time;
+ using std::chrono::milliseconds;
+
+ sys_time<milliseconds> tp{milliseconds{time_miliseconds}};
+ try {
+ const auto local_tz = locate_zone(std::string(timezone, length));
+ gdv_timestamp offset = local_tz->get_info(tp).offset.count() * 1000;
+ return time_miliseconds - static_cast<gdv_timestamp>(offset);
+ } catch (...) {
+ auto msg_len = static_cast<int32_t>(strlen(timezone) + 50);
Review Comment:
you can't use strlen since timezone is not a null terminated string. You can
simply do the following
```
std::string err_msg = std::string(timezone, length) + " is an invalid time
zone name.";
gdv_fn_context_set_error_msg(context, err_msg.c_str());
return 0;
--
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]