Skip to content

Commit

Permalink
Merge "Merge Android R"
Browse files Browse the repository at this point in the history
  • Loading branch information
delphij authored and Gerrit Code Review committed Sep 10, 2020
2 parents 1aea831 + e52edf0 commit f1445a6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/com/android/calendarcommon2/RecurrenceProcessor.java
Expand Up @@ -1235,7 +1235,7 @@ static int yearLength(int year) {
private static final int[] DAYS_PER_MONTH = { 31, 28, 31, 30, 31, 30, 31,
31, 30, 31, 30, 31 };
private static final int[] DAYS_IN_YEAR_PRECEDING_MONTH = { 0, 31, 59, 90,
120, 151, 180, 212, 243, 273, 304, 334 };
120, 151, 181, 212, 243, 273, 304, 334 };

/**
* Returns the number of days in the given month of the given year.
Expand Down
26 changes: 26 additions & 0 deletions tests/src/com/android/calendarcommon2/RecurrenceProcessorTest.java
Expand Up @@ -2534,4 +2534,30 @@ public void performanceTestNormalize() throws Exception {
Log.i(TAG, "date: " + date.format2445());
Log.i(TAG, "testPerformanceNormalize() unsafeNormalize() elapsed millis: " + elapsed);
}

@SmallTest
public void testYearDay() {
assertEquals(181, RecurrenceProcessor.yearDay(2019, 6, 1));

/* compare day of year in non leap year (2019) to leap year (2020). */

// january 1
assertEquals(0, RecurrenceProcessor.yearDay(2019, 0, 1));
assertEquals(0, RecurrenceProcessor.yearDay(2020, 0, 1));

// february 28
assertEquals(58, RecurrenceProcessor.yearDay(2019, 1, 28));
assertEquals(58, RecurrenceProcessor.yearDay(2020, 1, 28));

// february 29
assertEquals(59, RecurrenceProcessor.yearDay(2020, 1, 29));

// march 1
assertEquals(59, RecurrenceProcessor.yearDay(2019, 2, 1));
assertEquals(60, RecurrenceProcessor.yearDay(2020, 2, 1));

// december 31
assertEquals(364, RecurrenceProcessor.yearDay(2019, 11, 31));
assertEquals(365, RecurrenceProcessor.yearDay(2020, 11, 31));
}
}

0 comments on commit f1445a6

Please sign in to comment.