DileepSrigiri commented on a change in pull request #10160:
URL: https://github.com/apache/arrow/pull/10160#discussion_r630087656



##########
File path: cpp/src/gandiva/precompiled/timestamp_arithmetic.cc
##########
@@ -47,6 +47,28 @@ bool is_last_day_of_month(const EpochTimePoint& tp) {
   return !is_leap_year(tp.TmYear());
 }
 
+bool did_days_overflow(int year, int month, int days) {
+      int days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

Review comment:
       Done

##########
File path: cpp/src/gandiva/precompiled/epoch_time_point.h
##########
@@ -65,12 +73,22 @@ class EpochTimePoint {
                               .time_since_epoch());
   }
 
-  EpochTimePoint AddMonths(int num_months) const {
-    auto ymd = YearMonthDay() + arrow_vendored::date::months(num_months);
-    return EpochTimePoint((arrow_vendored::date::sys_days{ymd} +  // NOLINT
-                           TimeOfDay().to_duration())
-                              .time_since_epoch());
-  }
+    EpochTimePoint AddMonths(int num_months) const {
+      auto ymd = YearMonthDay() + arrow_vendored::date::months(num_months);
+
+      EpochTimePoint tp = EpochTimePoint((arrow_vendored::date::sys_days{ymd} 
+  // NOLINT
+                            TimeOfDay().to_duration())
+                                .time_since_epoch());
+
+      if(did_days_overflow(static_cast<int>(ymd.year()), static_cast<unsigned 
int>(ymd.month()), 

Review comment:
       Done




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to