aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-09-08 16:55:23 -0700
committerXin Li <delphij@google.com>2020-09-08 16:55:23 -0700
commite52edf0582f05d71432abd1a3b6dca1a5cc0e1ad (patch)
tree22fabdf2db0179ed308c4e72ce902bebd5fda3c0
parent1aea8315ebe9cca6e9462ab02e9f4caf20c8cd58 (diff)
parentdc37d34d50947eede476221bedef264622a5a7ac (diff)
downloadcalendar-e52edf0582f05d71432abd1a3b6dca1a5cc0e1ad.tar.gz
Merge Android R
Bug: 168057903 Merged-In: I89c5b4a70013ab98ec5428794ec301c5ef191af3 Change-Id: I080df3a9ab84136296895e9e83e9b05090c6bc87
-rw-r--r--src/com/android/calendarcommon2/RecurrenceProcessor.java2
-rw-r--r--tests/src/com/android/calendarcommon2/RecurrenceProcessorTest.java26
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));
+ }
}