kou commented on code in PR #13428:
URL: https://github.com/apache/arrow/pull/13428#discussion_r919776430


##########
cpp/src/gandiva/gdv_function_stubs.cc:
##########
@@ -611,6 +611,51 @@ 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 std::chrono::milliseconds;
+  using arrow_vendored::date::sys_time;
+  using arrow_vendored::date::time_zone;
+  using arrow_vendored::date::zoned_time;
+  using arrow_vendored::date::locate_zone;
+
+  sys_time <milliseconds> tp {milliseconds{time_miliseconds}};
+  try {
+    const time_zone* 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(...) {
+      gdv_fn_context_set_error_msg(context, "Invalid time zone");
+      return 0;
+  }
+}
+
+GANDIVA_EXPORT
+gdv_timestamp from_utc_timezone_timestamp(gdv_int64 context,
+                                          gdv_timestamp time_miliseconds,
+                                          const char* timezone, gdv_int32 
length) {
+  using std::chrono::milliseconds;
+  using arrow_vendored::date::sys_time;
+  using arrow_vendored::date::time_zone;
+  using arrow_vendored::date::zoned_time;
+  using arrow_vendored::date::make_zoned;
+
+  sys_time <milliseconds> tp {milliseconds{time_miliseconds}};
+  const zoned_time<milliseconds, const time_zone*> utc_tz =

Review Comment:
   It seems that 
https://github.com/palak-9202/arrow/commit/4c0549526e56866205e4b1baa993b2e3e67241d5#diff-6112a00ef24accb25d6dde3f15276ee354c695838994d2e80e0de65c0e1929abL100
 is the problem. 
https://github.com/palak-9202/arrow/commit/4c0549526e56866205e4b1baa993b2e3e67241d5#diff-6112a00ef24accb25d6dde3f15276ee354c695838994d2e80e0de65c0e1929abL102
 didn't cause the problem.
   The former uses `const char *` and the latter uses `std::string`.
   How about trying the above diff that uses `std::string` for the former?



-- 
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]

Reply via email to