Displaying differences for changeset
 
display as  

src/java/cfa/DoubleArray.java

@@ -26,7 +26,7 @@
     }
 }
 /**
-* Last Updated: 11-July-2014
+* Last Updated: 16-July-2014
 * @author Tyler Wible
 * @since 21-June-2012
 */
@@ -1334,20 +1334,7 @@
                     
                     //Check February for leap years (including the 100-year-not-leap-year and 400-year-leap-year)
                     }else if((Double.compare(month, 2) == 0)){
-                        boolean leapYear = false;
-                        double yearUp4 = Math.ceil(year/4);
-                        double yearDown4 = Math.floor(year/4);
-                        double yearUp100 = Math.ceil(year/100);
-                        double yearDown100 = Math.floor(year/100);
-                        double yearUp400 = Math.ceil(year/400);
-                        double yearDown400 = Math.floor(year/400);
-                        if(yearUp400 == yearDown400){
-                            leapYear = true;
-                        }else if(yearUp100 == yearDown100){
-                            leapYear = false;
-                        }else if(yearUp4 == yearDown4){
-                            leapYear = true;
-                        }
+                        boolean leapYear = getLeapYearTF((int) year);
                         //Check non-leap years (28 day February)
                         if(!leapYear  && (Double.compare(day, 28) == 0)){//Check if is subsequent day
                             subsequentDates = true;
@@ -1434,6 +1421,35 @@
         
         return nextDate;
     }
+    /**
+     * Determines if the provided year (as an integer) is a leap year or not taking into 
+     * account for leap years every 4 years, not every 100 years, and leap years every 
+     * 400 years (this has to do with round off errors in the length of a day that propagate 
+     * over time).  If support for >400 year leap year information is desired modify this subfunction.
+     * @param currentYear  an integer for the current year
+     * @return  true if the currentYear is a leap year, false otherwise
+     */
+    public boolean getLeapYearTF(int currentYear){
+        //Determine if the current year is a leap year (366 days) or not (365 days)
+        boolean leapYear = false;
+        double currentYear_db = (double) currentYear;
+
+        //Determine if this year is a leap year (divide by 4) and take into account every 100 years it is not a leap year and every 400 it is
+        double yearUp4        = Math.ceil(currentYear_db/4);
+        double yearDown4    = Math.floor(currentYear_db/4);
+        double yearUp100    = Math.ceil(currentYear_db/100);
+        double yearDown100    = Math.floor(currentYear_db/100);
+        double yearUp400    = Math.ceil(currentYear_db/400);
+        double yearDown400    = Math.floor(currentYear_db/400);
+        if(yearUp400 == yearDown400){
+            leapYear = true;
+        }else if(yearUp100 == yearDown100){
+            leapYear = false;
+        }else if(yearUp4 == yearDown4){
+            leapYear = true;
+        }
+        return leapYear;
+    }
 //    /**
 //     * Reduces all data to just that within the specified date range
 //     * @param allData  all water quality data for the earlier provided date range and station ID (column1 = date, column2 = value)

src/java/cfa/guiBaseflow_Model.java

@@ -29,7 +29,7 @@
 
 
 /**
- * Last Updated: 10-July-2014
+ * Last Updated: 16-July-2014
  * @author Tyler Wible
  * @since 15-June-2012
  */
@@ -574,33 +574,14 @@
     }
     /**
      * Determines if the provided year (as an integer) is a leap year or not
-     * taking into account for leap years every 4 years, not every 100 years,
-     * and leap years every 400 years (this has to do with round off errors in
-     * the length of a day that propagate over time). If support for >400 year
-     * leap year information is desired modify this subfunction.
      * @param currentYear the current year
      * @return an integer[] containing the number of days in each of the 4
      * 'weeks' of february (a WATSTORE file 'week')
      */
     private int[] checkFebLeapYear(int currentYear) {
         //Determine how many days February should have based on if it is a leap year or not
-        boolean leapYear = false;
-        double currentYear_db = (double) currentYear;
-
-        //Determine if this year is a leap year (divide by 4) and take into account every 100 years it is not a leap year and every 400 it is
-        double yearUp4 = Math.ceil(currentYear_db / 4);
-        double yearDown4 = Math.floor(currentYear_db / 4);
-        double yearUp100 = Math.ceil(currentYear_db / 100);
-        double yearDown100 = Math.floor(currentYear_db / 100);
-        double yearUp400 = Math.ceil(currentYear_db / 400);
-        double yearDown400 = Math.floor(currentYear_db / 400);
-        if (yearUp400 == yearDown400) {
-            leapYear = true;
-        } else if (yearUp100 == yearDown100) {
-            leapYear = false;
-        } else if (yearUp4 == yearDown4) {
-            leapYear = true;
-        }
+        DoubleArray doubleArray = new DoubleArray();
+        boolean leapYear = doubleArray.getLeapYearTF(currentYear);
 
         //Based on the leap year or not determine the number of days in February
         int[] feb = {8, 8, 8, 4};
@@ -864,32 +845,14 @@
         return numberOfDays;
     }
     /**
-     * Determines if the provided year (as an integer) is a leap year or not taking into 
-     * account for leap years every 4 years, not every 100 years, and leap years every 
-     * 400 years (this has to do with round off errors in the length of a day that propagate 
-     * over time).  If support for >400 year leap year information is desired modify this subfunction.
+     * Determines if the provided year (as an integer) is a leap year or not
      * @param currentYear  the current year
      * @return  an integer number of days in the forth 'week' of february (a WATSTORE file 'week')
      */
     private int checkWATSTOREleapYear(int currentYear){
         //Determine how many days February should have based on if it is a leap year or not
-        boolean leapYear = false;
-        double currentYear_db = (double) currentYear;
-
-        //Determine if this year is a leap year (divide by 4) and take into account every 100 years it is not a leap year and every 400 it is
-        double yearUp4        = Math.ceil(currentYear_db/4);
-        double yearDown4    = Math.floor(currentYear_db/4);
-        double yearUp100    = Math.ceil(currentYear_db/100);
-        double yearDown100    = Math.floor(currentYear_db/100);
-        double yearUp400    = Math.ceil(currentYear_db/400);
-        double yearDown400    = Math.floor(currentYear_db/400);
-        if(yearUp400 == yearDown400){
-            leapYear = true;
-        }else if(yearUp100 == yearDown100){
-            leapYear = false;
-        }else if(yearUp4 == yearDown4){
-            leapYear = true;
-        }
+        DoubleArray doubleArray = new DoubleArray();
+        boolean leapYear = doubleArray.getLeapYearTF(currentYear);
 
         //Based on the leap year or not determine the number of days in February
         int feb = 4;