rok commented on a change in pull request #10457:
URL: https://github.com/apache/arrow/pull/10457#discussion_r688207105
##########
File path: cpp/src/arrow/compute/kernels/scalar_temporal.cc
##########
@@ -187,16 +243,28 @@ struct DayOfYear {
template <typename Duration>
struct ISOYear {
+ explicit ISOYear(const time_zone* tz = nullptr) : tz_(tz) {}
+
template <typename T, typename Arg0>
- static T Call(KernelContext*, Arg0 arg, Status*) {
- const auto t = floor<days>(sys_time<Duration>(Duration{arg}));
+ T Call(KernelContext*, Arg0 arg, Status*) const {
+ if (tz_ == nullptr) {
+ const auto t = floor<days>(sys_time<Duration>(Duration{arg}));
+ auto y = year_month_day{t + days{3}}.year();
+ auto start = sys_time<days>((y - years{1}) / dec / thu[last]) + (mon -
thu);
+ if (t < start) {
+ --y;
+ }
+ return static_cast<T>(static_cast<int32_t>(y));
+ }
+ const auto t =
floor<days>(tz_->to_local(sys_time<Duration>(Duration{arg})));
auto y = year_month_day{t + days{3}}.year();
- auto start = sys_time<days>((y - years{1}) / dec / thu[last]) + (mon -
thu);
+ auto start = local_days((y - years{1}) / dec / thu[last]) + (mon - thu);
if (t < start) {
Review comment:
I've adjusted your proposal to work with `ScalarUnaryNotNullStateful`.
--
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]