]> WPIA git - gigi.git/blobdiff - tests/club/wpia/gigi/TestCalendarUtil.java
fix: correct validation of minimum and maximum ages
[gigi.git] / tests / club / wpia / gigi / TestCalendarUtil.java
index 5bed6e56305561ba7c18ed7502771c9fa64f7ccd..25685e7a576205d1b37ad360a917a4bcf02375d9 100644 (file)
@@ -47,8 +47,11 @@ public class TestCalendarUtil {
         assertTrue(CalendarUtil.isOfAge(dob, 13));
 
         assertTrue(CalendarUtil.isOfAge(dob, 14));
         assertTrue(CalendarUtil.isOfAge(dob, 13));
 
         assertTrue(CalendarUtil.isOfAge(dob, 14));
-
-        dob = CalendarUtil.getDateFromComponents(year - 14, month, days + 1);
+        // We need one day as safety margin. Between 10:00 and 23:59 UTC there
+        // is a place on earth (UTC+1 to UTC+14) where a person having
+        // birthday "tomorrow" is already of that age. So we need the day after
+        // tomorrow for doing this check the easy way.
+        dob = CalendarUtil.getDateFromComponents(year - 14, month, days + 2);
         assertFalse(CalendarUtil.isOfAge(dob, 14));
 
     }
         assertFalse(CalendarUtil.isOfAge(dob, 14));
 
     }