diff options
author | Xin Li <delphij@google.com> | 2020-09-10 17:22:18 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-09-10 17:22:18 +0000 |
commit | f1445a64e794bf50ffc1dc587ee90121551b68df (patch) | |
tree | 22fabdf2db0179ed308c4e72ce902bebd5fda3c0 | |
parent | 1aea8315ebe9cca6e9462ab02e9f4caf20c8cd58 (diff) | |
parent | e52edf0582f05d71432abd1a3b6dca1a5cc0e1ad (diff) | |
download | calendar-f1445a64e794bf50ffc1dc587ee90121551b68df.tar.gz |
Merge "Merge Android R"
-rw-r--r-- | src/com/android/calendarcommon2/RecurrenceProcessor.java | 2 | ||||
-rw-r--r-- | tests/src/com/android/calendarcommon2/RecurrenceProcessorTest.java | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/com/android/calendarcommon2/RecurrenceProcessor.java b/src/com/android/calendarcommon2/RecurrenceProcessor.java index fd225db..d0a647a 100644 --- a/src/com/android/calendarcommon2/RecurrenceProcessor.java +++ b/src/com/android/calendarcommon2/RecurrenceProcessor.java @@ -1235,7 +1235,7 @@ bysetpos: 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. diff --git a/tests/src/com/android/calendarcommon2/RecurrenceProcessorTest.java b/tests/src/com/android/calendarcommon2/RecurrenceProcessorTest.java index af850f8..3503aae 100644 --- a/tests/src/com/android/calendarcommon2/RecurrenceProcessorTest.java +++ b/tests/src/com/android/calendarcommon2/RecurrenceProcessorTest.java @@ -2534,4 +2534,30 @@ public class RecurrenceProcessorTest extends TestCase { 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)); + } } |