rok commented on code in PR #12865:
URL: https://github.com/apache/arrow/pull/12865#discussion_r2207962686


##########
cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc:
##########
@@ -1353,31 +1353,44 @@ Result<TypeHolder> 
ResolveLocalTimestampOutput(KernelContext* ctx,
 
 template <typename Duration>
 struct AssumeTimezone {
-  explicit AssumeTimezone(const AssumeTimezoneOptions* options, const 
time_zone* tz)
-      : options(*options), tz_(tz) {}
+  explicit AssumeTimezone(const AssumeTimezoneOptions* options, const 
ArrowTimeZone* tz)
+      : options(*options), tz_(*tz) {}
 
   template <typename T, typename Arg0>
-  T get_local_time(Arg0 arg, const time_zone* tz) const {
-    return static_cast<T>(zoned_time<Duration>(tz, 
local_time<Duration>(Duration{arg}))
-                              .get_sys_time()
-                              .time_since_epoch()
-                              .count());
+  T get_local_time(Arg0 arg, const ArrowTimeZone* tz) const {
+    const auto visitor =
+        overloads{[arg](const time_zone* tz) {
+                    return zoned_time<Duration>{tz, 
local_time<Duration>(Duration{arg})}
+                        .get_sys_time();
+                  },
+                  [arg](const OffsetZone tz) {
+                    return zoned_time<Duration, const OffsetZone*>{
+                        &tz, local_time<Duration>(Duration{arg})}
+                        .get_sys_time();
+                  }};
+    return std::visit(visitor, tz_).time_since_epoch().count();
   }
 
   template <typename T, typename Arg0>
   T get_local_time(Arg0 arg, const arrow_vendored::date::choose choose,
-                   const time_zone* tz) const {
-    return static_cast<T>(
-        zoned_time<Duration>(tz, local_time<Duration>(Duration{arg}), choose)
-            .get_sys_time()
-            .time_since_epoch()
-            .count());
+                   const ArrowTimeZone* tz) const {
+    const auto visitor = overloads{[arg, choose](const time_zone* tz) {
+                                     return zoned_time<Duration>{
+                                         tz, 
local_time<Duration>(Duration{arg}), choose}
+                                         .get_sys_time();
+                                   },
+                                   [arg, choose](const OffsetZone tz) {
+                                     return zoned_time<Duration, const 
OffsetZone*>{
+                                         &tz, 
local_time<Duration>(Duration{arg}), choose}
+                                         .get_sys_time();
+                                   }};
+    return static_cast<T>(std::visit(visitor, tz_).time_since_epoch().count());

Review Comment:
   This throws:
   ```cpp
   `std::visit` requires the visitor to have a single return type.
   ```



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to