static int countInPeriod ( Weekday dow , Weekday dow0 , int nDays ) { // Two cases // (1a) dow >= dow0: count === (nDays - (dow - dow0)) / 7 // (1b) dow < dow0: count === (nDays - (7 - dow0 - dow)) / 7 if ( dow . javaDayNum >= dow0 . javaDayNum ) { return 1 + ( ( nDays - ( dow . javaDayNum - dow0 . javaDayNum ) - 1 ) / 7 ) ; } else { return 1 + ( ( nDays - ( 7 - ( dow0 . javaDayNum - dow . javaDayNum ) ) - 1 ) / 7 ) ; } }
the number of occurences of dow in a period nDays long where the first day of the period has day of week dow0 .