int dyold = minD.dayOfYear();
int dold = minD.dayOfMonth();
int mold = minD.month().value();
int yold = minD.year();
Weekday wdold = minD.weekday();
final Date minDate = minD.clone().inc();
final Date maxDate = maxD.clone().dec();
for (final Date t = minDate; t.le(maxDate); t.inc()) {
final int dy = t.dayOfYear();
final int d = t.dayOfMonth();
final int m = t.month().value();
final int y = t.year();
final Weekday wd = t.weekday();
// check if skipping any date
if (!((dy == dyold + 1)
|| (dy == 1 && dyold == 365 && !Date.isLeap(yold))
|| (dy == 1 && dyold == 366 && Date.isLeap(yold)))) {
fail("wrong day of year increment: \n"
+ " date: " + t + "\n"
+ " day of year: " + dy + "\n"
+ " previous: " + dyold);
}
dyold = dy;
if (!((d == dold + 1 && m == mold && y == yold) || (d == 1 && m == mold + 1 && y == yold) || (d == 1 && m == 1 && y == yold + 1)) ) {
fail("wrong day,month,year increment: \n"
+ " date: " + t + "\n"
+ " day,month,year: " + d + "," + m + "," + y + "\n"
+ " previous: " + dold + "," + mold + "," + yold);
}
dold = d;
mold = m;
yold = y;
// check month definition
if ((m < 1 || m > 12)) {
fail("invalid month: \n" + " date: " + t + "\n" + " month: " + m);
}
// check day definition
if ((d < 1)) {
fail("invalid day of month: \n" + " date: " + t + "\n" + " day: " + d);
}
if (!((m == 1 && d <= 31)
|| (m == 2 && d <= 28) || (m == 2 && d == 29 && Date.isLeap(y))
|| (m == 3 && d <= 31) || (m == 4 && d <= 30) || (m == 5 && d <= 31) || (m == 6 && d <= 30)
|| (m == 7 && d <= 31) || (m == 8 && d <= 31) || (m == 9 && d <= 30) || (m == 10 && d <= 31)
|| (m == 11 && d <= 30) || (m == 12 && d <= 31))) {
fail("invalid day of month: \n" + " date: " + t + "\n" + " day: " + d);
}
// check weekday definition
if (!((wd.value() == wdold.value() + 1) || (wd.value() == 1 && wdold.value() == 7))) {
fail("invalid weekday: \n"
+ " date: " + t + "\n"
+ " weekday: " + wd + "\n"
+ " previous: " + wdold);
}