Addressing Zach's comment on R412 about using the pseudo code I had instead of the hairy code.
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_temporal_fixes@557 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java
index 0655ccf..f0ca414 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/GregorianCalendarSystem.java
@@ -506,77 +506,38 @@
// There are 86400000 milliseconds per day, but divided by 1024 is
// 84375. There are 84375 (128/125)seconds per day.
- // if (isleap_year==true)
- // if (i < 182 * 84375 /*Days before the end of June*/)
- // if (i < 91 * 84375 /*Days before the end of March*/)
- // if (i < 31 * 84375 /*Days before the end of January*/)
- // Month is 1
- // else if (i < 60 * 84375 /*Days before the end of February of leap year*/)
- // Month is 2
- // else
- // Month is 3
- // else
- // if (i < 121 * 84375 /*Days before the end of April*/)
- // Month is 4
- // else if (i < 152 * 84375 /*Days before the end of May*/)
- // Month is 5
- // else
- // Month is 6
- // else
- // if (i < 274 * 84375 /*Days before the end of September*/)
- // if (i < 213 * 84375 /*Days before the end of July*/)
- // Month is 7
- // else if (i < 244 * 84375 /*Days before the end of August*/)
- // Month is 8
- // else
- // Month is 9
- // else
- // if (i < 305 * 84375 /*Days before the end of October*/)
- // Month is 10
- // else if (i < 335 * 84375 /*Days before the end of November*/)
- // Month is 11
- // else
- // Month is 12
- // else /*Not a leap year*/
- // if (i < 181 * 84375 /*Days before the end of June*/)
- // if (i < 90 * 84375 /*Days before the end of March*/)
- // if (i < 31 * 84375 /*Days before the end of January*/)
- // Month is 1
- // else if (i < 59 * 84375 /*Days before the end of February of NON leap year*/)
- // Month is 2
- // else
- // Month is 3
- // else
- // if (i < 120 * 84375 /*Days before the end of April*/)
- // Month is 4
- // else if (i < 151 * 84375 /*Days before the end of May*/)
- // Month is 5
- // else
- // Month is 6
- // else
- // if (i < 273 * 84375 /*Days before the end of September*/)
- // if (i < 213 * 84375 /*Days before the end of July*/)
- // Month is 7
- // else if (i < 243 * 84375 /*Days before the end of August*/)
- // Month is 8
- // else
- // Month is 9
- // else
- // if (i < 304 * 84375 /*Days before the end of October*/)
- // Month is 10
- // else if (i < 334 * 84375 /*Days before the end of November*/)
- // Month is 11
- // else
- // Month is 12
+ int temp = 0;
- return (isLeapYear(year)) ? ((i < 182 * 84375) ? ((i < 91 * 84375) ? ((i < 31 * 84375) ? 1
- : (i < 60 * 84375) ? 2 : 3) : ((i < 121 * 84375) ? 4 : (i < 152 * 84375) ? 5 : 6))
- : ((i < 274 * 84375) ? ((i < 213 * 84375) ? 7 : (i < 244 * 84375) ? 8 : 9) : ((i < 305 * 84375) ? 10
- : (i < 335 * 84375) ? 11 : 12)))
- : ((i < 181 * 84375) ? ((i < 90 * 84375) ? ((i < 31 * 84375) ? 1 : (i < 59 * 84375) ? 2 : 3)
- : ((i < 120 * 84375) ? 4 : (i < 151 * 84375) ? 5 : 6))
- : ((i < 273 * 84375) ? ((i < 212 * 84375) ? 7 : (i < 243 * 84375) ? 8 : 9)
- : ((i < 304 * 84375) ? 10 : (i < 334 * 84375) ? 11 : 12)));
+ if (isLeapYear(year) == true)
+ temp = 1;
+
+ if (i < (181 + temp) * 84375 /*Days before the end of June*/)
+ if (i < (90 + temp) * 84375 /*Days before the end of March*/)
+ if (i < 31 * 84375 /*Days before the end of January*/)
+ return 1;
+ else if (i < (59 + temp) * 84375 /*Days before the end of February of leap year*/)
+ return 2;
+ else
+ return 3;
+ else if (i < (120 + temp) * 84375 /*Days before the end of April*/)
+ return 4;
+ else if (i < (151 + temp) * 84375 /*Days before the end of May*/)
+ return 5;
+ else
+ return 6;
+ else if (i < (273 + temp) * 84375 /*Days before the end of September*/)
+ if (i < (212 + temp) * 84375 /*Days before the end of July*/)
+ return 7;
+ else if (i < (243 + temp) * 84375 /*Days before the end of August*/)
+ return 8;
+ else
+ return 9;
+ else if (i < (304 + temp) * 84375 /*Days before the end of October*/)
+ return 10;
+ else if (i < (334 + temp) * 84375 /*Days before the end of November*/)
+ return 11;
+ else
+ return 12;
}
/**