- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
// See where we currently are in a calendar quarter.
// In Java, JANUARY == 0.
// Yes, I could just write (3 - currentMonth % 3),
// but this is clearer
switch (currentMonth % 3) {
case 0: // January, April, July, October
monthsToInclude = 3; // include whole last quarter
break;
case 1: // February, May, August, November
monthsToInclude = 2; // include first two months of this quarter
break;
default: // March, June, September, December
monthsToInclude = 1; // include first month of this quarter
break;
}
Или всё-таки наплевать на читаемость и заменить короткой версией?