rok commented on a change in pull request #10960: URL: https://github.com/apache/arrow/pull/10960#discussion_r717025312
########## File path: cpp/src/arrow/compute/kernels/scalar_temporal.cc ########## @@ -776,6 +840,188 @@ struct ISOCalendar { } }; +// ---------------------------------------------------------------------- +// Compute boundary crossings between two timestamps + +template <typename Duration, typename Localizer> +struct YearsBetween { + YearsBetween(const FunctionOptions* options, Localizer&& localizer) + : localizer_(std::move(localizer)) {} + + template <typename T, typename Arg0, typename Arg1> + T Call(KernelContext*, Arg0 arg0, Arg1 arg1, Status*) const { + year_month_day from( + floor<days>(localizer_.template ConvertTimePoint<Duration>(arg0))); + year_month_day to(floor<days>(localizer_.template ConvertTimePoint<Duration>(arg1))); + return static_cast<T>((to.year() - from.year()).count()); + } + + Localizer localizer_; +}; + +template <typename Duration, typename Localizer> +struct QuartersBetween { + QuartersBetween(const FunctionOptions* options, Localizer&& localizer) + : localizer_(std::move(localizer)) {} + + static int64_t GetQuarters(const year_month_day& ymd) { + return static_cast<int64_t>(static_cast<int32_t>(ymd.year())) * 4 + + (static_cast<uint32_t>(ymd.month()) - 1) / 3; + } Review comment: I mean this: https://github.com/apache/arrow/blob/7124872e99673d1087e7c547babf0fb3dd2634d7/cpp/src/arrow/compute/kernels/scalar_temporal.cc#L405-L410 -- 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