[ASTERIXDB-2352][FUN] Incorrect leap year handling in duration arithmetic

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- DurationArithmeticOperations.addDuration() incorrectly handled leap year

Change-Id: I01e1417f4704d72a4650ec4f2fa257f044a20a09
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2561
Reviewed-by: Till Westmann <ti...@apache.org>
Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/8db70084
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/8db70084
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/8db70084

Branch: refs/heads/release-0.9.4-pre-rc
Commit: 8db70084f0593983af6ed877ccf50553dec4649c
Parents: 366edf8
Author: Dmitry Lychagin <dmitry.lycha...@couchbase.com>
Authored: Mon Apr 2 15:36:46 2018 -0700
Committer: Dmitry Lychagin <dmitry.lycha...@couchbase.com>
Committed: Mon Apr 2 19:24:52 2018 -0700

----------------------------------------------------------------------
 .../om/base/temporal/DurationArithmeticOperations.java       | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8db70084/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/temporal/DurationArithmeticOperations.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/temporal/DurationArithmeticOperations.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/temporal/DurationArithmeticOperations.java
index a50adc6..26c3fb3 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/temporal/DurationArithmeticOperations.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/temporal/DurationArithmeticOperations.java
@@ -85,13 +85,13 @@ public class DurationArithmeticOperations {
         boolean isLeapYear = GREG_CAL.isLeapYear(year);
 
         if (isLeapYear) {
-            if (day > GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[month - 1]) {
-                day = GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[month - 1];
-            }
-        } else {
             if (day > GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[month - 1]) {
                 day = GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[month - 1];
             }
+        } else {
+            if (day > GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[month - 1]) {
+                day = GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[month - 1];
+            }
         }
 
         return GREG_CAL.getChronon(year, month, day, hour, min, sec, ms, 0) + 
dayTimeDuration;

Reply via email to