diff options
author | Elliott Hughes <enh@google.com> | 2014-06-27 00:18:48 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-06-26 17:56:55 +0000 |
commit | a9640416956fac998d3a69ec05ded7eaec80dddf (patch) | |
tree | 6fe2ad783dad0d46697638d0af7d2a608e7cdc8e /luni/src/test/java | |
parent | 906d1caac9ab8c8b108ed4be244ba4eee58739e5 (diff) | |
parent | fda7c027e360292edfa4d32fadd2844efaa5f9d7 (diff) | |
download | libcore-a9640416956fac998d3a69ec05ded7eaec80dddf.zip libcore-a9640416956fac998d3a69ec05ded7eaec80dddf.tar.gz libcore-a9640416956fac998d3a69ec05ded7eaec80dddf.tar.bz2 |
Merge "Fix a faulty Julian day computation."
Diffstat (limited to 'luni/src/test/java')
-rw-r--r-- | luni/src/test/java/libcore/icu/DateIntervalFormatTest.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java b/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java index 18228f9..bac8138 100644 --- a/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java +++ b/luni/src/test/java/libcore/icu/DateIntervalFormatTest.java @@ -38,6 +38,7 @@ public class DateIntervalFormatTest extends junit.framework.TestCase { c.set(Calendar.HOUR_OF_DAY, 3); c.set(Calendar.MINUTE, 30); c.set(Calendar.SECOND, 15); + c.set(Calendar.MILLISECOND, 0); long timeWithCurrentYear = c.getTimeInMillis(); c.set(Calendar.YEAR, 2009); @@ -169,6 +170,7 @@ public class DateIntervalFormatTest extends junit.framework.TestCase { Locale l = Locale.US; TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles"); Calendar c = Calendar.getInstance(tz, l); + c.clear(); c.set(2042, Calendar.JANUARY, 19, 3, 30); long jan_19_2042 = c.getTimeInMillis(); c.set(2046, Calendar.OCTOBER, 4, 3, 30); @@ -261,6 +263,45 @@ public class DateIntervalFormatTest extends junit.framework.TestCase { assertEquals("January 1, 1970, 22:00 – January 2, 1970, 00:30", formatDateRange(l, utc, 22 * HOUR, 24 * HOUR + 30 * MINUTE, flags)); } + // The fix for http://b/10560853 didn't work except for the day around the epoch, which was + // all the unit test checked! + public void test_single_day_events_later_than_epoch() throws Exception { + Locale l = Locale.US; + TimeZone utc = TimeZone.getTimeZone("UTC"); + + int flags = FORMAT_SHOW_TIME | FORMAT_24HOUR | FORMAT_SHOW_DATE; + + Calendar c = Calendar.getInstance(utc, l); + c.clear(); + c.set(1980, Calendar.JANUARY, 1, 0, 0); + long jan_1_1980 = c.getTimeInMillis(); + assertEquals("January 1, 1980, 22:00 – 00:00", + formatDateRange(l, utc, jan_1_1980 + 22 * HOUR, jan_1_1980 + 24 * HOUR, flags)); + assertEquals("January 1, 1980, 22:00 – January 2, 1980, 00:30", + formatDateRange(l, utc, jan_1_1980 + 22 * HOUR, jan_1_1980 + 24 * HOUR + 30 * MINUTE, flags)); + } + + // The fix for http://b/10560853 didn't work except for UTC, which was + // all the unit test checked! + public void test_single_day_events_not_in_UTC() throws Exception { + Locale l = Locale.US; + TimeZone pacific = TimeZone.getTimeZone("America/Los_Angeles"); + + int flags = FORMAT_SHOW_TIME | FORMAT_24HOUR | FORMAT_SHOW_DATE; + + Calendar c = Calendar.getInstance(pacific, l); + c.clear(); + c.set(1980, Calendar.JANUARY, 1, 0, 0); + long jan_1_1980 = c.getTimeInMillis(); + assertEquals("January 1, 1980, 22:00 – 00:00", + formatDateRange(l, pacific, jan_1_1980 + 22 * HOUR, jan_1_1980 + 24 * HOUR, flags)); + + c.set(1980, Calendar.JULY, 1, 0, 0); + long jul_1_1980 = c.getTimeInMillis(); + assertEquals("July 1, 1980, 22:00 – 00:00", + formatDateRange(l, pacific, jul_1_1980 + 22 * HOUR, jul_1_1980 + 24 * HOUR, flags)); + } + // http://b/10209343 - even if the caller didn't explicitly ask us to include the year, // we should do so for years other than the current year. public void test10209343_when_not_this_year() { @@ -343,6 +384,7 @@ public class DateIntervalFormatTest extends junit.framework.TestCase { public void test12004664() throws Exception { TimeZone utc = TimeZone.getTimeZone("UTC"); Calendar c = Calendar.getInstance(utc, Locale.US); + c.clear(); c.set(Calendar.YEAR, 1980); c.set(Calendar.MONTH, Calendar.FEBRUARY); c.set(Calendar.DAY_OF_MONTH, 10); |