@@ -36,8 +36,7 @@ namespace arrow {
3636using internal::checked_cast;
3737using internal::checked_pointer_cast;
3838
39- namespace compute {
40- namespace internal {
39+ namespace compute ::internal {
4140
4241namespace {
4342
@@ -60,7 +59,6 @@ using arrow_vendored::date::year;
6059using arrow_vendored::date::year_month_day;
6160using arrow_vendored::date::year_month_weekday;
6261using arrow_vendored::date::years;
63- using arrow_vendored::date::zoned_time;
6462using arrow_vendored::date::literals::dec;
6563using arrow_vendored::date::literals::jan;
6664using arrow_vendored::date::literals::last;
@@ -664,15 +662,19 @@ struct Nanosecond {
664662
665663template <typename Duration>
666664struct IsDaylightSavings {
667- explicit IsDaylightSavings (const FunctionOptions* options, const time_zone* tz)
665+ explicit IsDaylightSavings (const FunctionOptions* options, const ArrowTimeZone tz)
668666 : tz_(tz) {}
669667
670668 template <typename T, typename Arg0>
671669 T Call (KernelContext*, Arg0 arg, Status*) const {
672- return tz_->get_info (sys_time<Duration>{Duration{arg}}).save .count () != 0 ;
670+ return std::visit (
671+ [&arg](const auto & tz) -> bool {
672+ return tz->get_info (sys_time<Duration>{Duration{arg}}).save .count () != 0 ;
673+ },
674+ tz_);
673675 }
674676
675- const time_zone* tz_;
677+ const ArrowTimeZone tz_;
676678};
677679
678680// ----------------------------------------------------------------------
@@ -1166,7 +1168,7 @@ Result<std::locale> GetLocale(const std::string& locale) {
11661168template <typename Duration, typename InType>
11671169struct Strftime {
11681170 const StrftimeOptions& options;
1169- const time_zone* tz;
1171+ const ArrowTimeZone tz;
11701172 const std::locale locale;
11711173
11721174 static Result<Strftime> Make (KernelContext* ctx, const DataType& type) {
@@ -1187,9 +1189,7 @@ struct Strftime {
11871189 options.format );
11881190 }
11891191 }
1190-
1191- ARROW_ASSIGN_OR_RAISE (const time_zone* tz,
1192- LocateZone (timezone.empty () ? " UTC" : timezone));
1192+ ARROW_ASSIGN_OR_RAISE (auto tz, LocateZone (timezone.empty () ? " UTC" : timezone));
11931193
11941194 ARROW_ASSIGN_OR_RAISE (std::locale locale, GetLocale (options.locale ));
11951195
@@ -1354,31 +1354,31 @@ Result<TypeHolder> ResolveLocalTimestampOutput(KernelContext* ctx,
13541354
13551355template <typename Duration>
13561356struct AssumeTimezone {
1357- explicit AssumeTimezone (const AssumeTimezoneOptions* options, const time_zone* tz)
1357+ explicit AssumeTimezone (const AssumeTimezoneOptions* options, const ArrowTimeZone tz)
13581358 : options(*options), tz_(tz) {}
13591359
13601360 template <typename T, typename Arg0>
1361- T get_local_time (Arg0 arg, const time_zone* tz) const {
1362- return static_cast <T>(zoned_time<Duration>(tz, local_time<Duration>(Duration{arg}))
1363- .get_sys_time ()
1364- .time_since_epoch ()
1365- .count ());
1361+ T get_local_time (Arg0 arg, const ArrowTimeZone* tz) const {
1362+ const auto lt = local_time<Duration>(Duration{arg});
1363+ auto local_to_sys_time = [&](auto && t) {
1364+ return t.get_sys_time ().time_since_epoch ().count ();
1365+ };
1366+ return ApplyTimeZone (tz_, lt, std::nullopt , local_to_sys_time);
13661367 }
13671368
13681369 template <typename T, typename Arg0>
1369- T get_local_time (Arg0 arg, const arrow_vendored::date::choose choose,
1370- const time_zone* tz) const {
1371- return static_cast <T>(
1372- zoned_time<Duration>(tz, local_time<Duration>(Duration{arg}), choose)
1373- .get_sys_time ()
1374- .time_since_epoch ()
1375- .count ());
1370+ T get_local_time (Arg0 arg, const choose c, const ArrowTimeZone* tz) const {
1371+ const auto lt = local_time<Duration>(Duration{arg});
1372+ auto local_to_sys_time = [&](auto && t) {
1373+ return t.get_sys_time ().time_since_epoch ().count ();
1374+ };
1375+ return ApplyTimeZone (tz_, lt, c, local_to_sys_time);
13761376 }
13771377
13781378 template <typename T, typename Arg0>
13791379 T Call (KernelContext*, Arg0 arg, Status* st) const {
13801380 try {
1381- return get_local_time<T, Arg0>(arg, tz_);
1381+ return get_local_time<T, Arg0>(arg, & tz_);
13821382 } catch (const arrow_vendored::date::nonexistent_local_time& e) {
13831383 switch (options.nonexistent ) {
13841384 case AssumeTimezoneOptions::Nonexistent::NONEXISTENT_RAISE: {
@@ -1387,11 +1387,12 @@ struct AssumeTimezone {
13871387 return arg;
13881388 }
13891389 case AssumeTimezoneOptions::Nonexistent::NONEXISTENT_EARLIEST: {
1390- return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest, tz_) -
1390+ return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest,
1391+ &tz_) -
13911392 1 ;
13921393 }
13931394 case AssumeTimezoneOptions::Nonexistent::NONEXISTENT_LATEST: {
1394- return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest, tz_);
1395+ return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest, & tz_);
13951396 }
13961397 }
13971398 } catch (const arrow_vendored::date::ambiguous_local_time& e) {
@@ -1403,17 +1404,17 @@ struct AssumeTimezone {
14031404 }
14041405 case AssumeTimezoneOptions::Ambiguous::AMBIGUOUS_EARLIEST: {
14051406 return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::earliest,
1406- tz_);
1407+ & tz_);
14071408 }
14081409 case AssumeTimezoneOptions::Ambiguous::AMBIGUOUS_LATEST: {
1409- return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest, tz_);
1410+ return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest, & tz_);
14101411 }
14111412 }
14121413 }
14131414 return 0 ;
14141415 }
14151416 AssumeTimezoneOptions options;
1416- const time_zone* tz_;
1417+ const ArrowTimeZone tz_;
14171418};
14181419
14191420// ----------------------------------------------------------------------
@@ -2035,6 +2036,5 @@ void RegisterScalarTemporalUnary(FunctionRegistry* registry) {
20352036 DCHECK_OK (registry->AddFunction (std::move (round_temporal)));
20362037}
20372038
2038- } // namespace internal
2039- } // namespace compute
2039+ } // namespace compute::internal
20402040} // namespace arrow
0 commit comments