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


##########
cpp/src/arrow/compute/kernels/temporal_internal.h:
##########
@@ -40,15 +39,42 @@ using arrow_vendored::date::year_month_day;
 using arrow_vendored::date::zoned_time;
 using std::chrono::duration_cast;
 
+using ArrowTimeZone = std::variant<const time_zone*, const OffsetZone>;
+
+template <class... Ts>
+struct overloads : Ts... {
+  using Ts::operator()...;
+};
+template <class... Ts>
+overloads(Ts...) -> overloads<Ts...>;
+
 inline int64_t GetQuarter(const year_month_day& ymd) {
   return static_cast<int64_t>((static_cast<uint32_t>(ymd.month()) - 1) / 3);
 }
 
-static inline Result<const time_zone*> LocateZone(const std::string& timezone) 
{
+static inline Result<const ArrowTimeZone> LocateZone(const std::string& 
timezone) {
   try {
-    return locate_zone(timezone);
+    const char* timezone_string = timezone.c_str();
+    if ((timezone_string[0] == '+' || timezone_string[0] == '-') &&
+        (timezone.length() == 5 || timezone.length() == 6)) {
+      // Valid offset strings have to have 4 digits and a sign prefix.
+      // Valid examples: +01:23 and -0123, invalid examples: 1:23, 123, 0123, 
01:23.
+      std::chrono::minutes zone_offset;
+      if (timezone.length() == 6) {
+        arrow::internal::detail::ParseHH_MM(timezone_string + 1, &zone_offset);
+      } else {
+        arrow::internal::detail::ParseHHMM(timezone_string + 1, &zone_offset);

Review Comment:
   I'm not expecting these to throw, just return false. Added checks for that 
and simplified a little bit.



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