Exemple #1
0
 public void test_weekOfMonth_getValue_sun7() {
   // July 2011 starts on a Friday
   // Fri/Sat 1st/2nd are week 0
   DateTimeRule rule = WeekRules.of(SUNDAY, 7).weekOfMonth();
   for (int i = 1; i <= 31; i++) {
     int w = MathUtils.floorDiv(i - 3, 7) + 1; // 3rd is start of week 1
     assertEquals(rule.getValue(LocalDate.of(2011, 7, i)), rule.field(w));
   }
 }
Exemple #2
0
 public void test_weekOfMonth_buildDate_sun7() {
   // July 2011 starts on a Friday
   // Fri/Sat 1st/2nd are week 0
   WeekRules wr = WeekRules.of(SUNDAY, 7);
   for (int i = 1; i <= 31; i++) {
     int w = MathUtils.floorDiv(i - 3, 7) + 1;
     int d = MathUtils.floorMod(i - 3, 7) + 1;
     CalendricalEngine engine =
         CalendricalEngine.merge(
             YearMonth.of(2011, JULY), wr.weekOfMonth().field(w), wr.dayOfWeek().field(d));
     assertEquals(engine.derive(LocalDate.rule()), LocalDate.of(2011, JULY, i));
   }
 }