]> granicus.if.org Git - icu/commitdiff
ICU-10061 (J) Make getDayOfWeekType behave as documented for last weekend day; fix...
authorPeter Edberg <pedberg@unicode.org>
Thu, 27 Jun 2013 06:53:35 +0000 (06:53 +0000)
committerPeter Edberg <pedberg@unicode.org>
Thu, 27 Jun 2013 06:53:35 +0000 (06:53 +0000)
X-SVN-Rev: 33858

icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java

index f8a9e753ed989af3575c6b680e684da916408fce..b28cb5223d7d8bf89f19f9999c68b1bf42c2e168 100644 (file)
@@ -4360,9 +4360,10 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
 
     /**
      * {@icu} Returns whether the given day of the week is a weekday, a
-     * weekend day, or a day that transitions from one to the other,
-     * in this calendar system.  If a transition occurs at midnight,
-     * then the days before and after the transition will have the
+     * weekend day, or a day that transitions from one to the other, for the
+     * locale and calendar system associated with this Calendar (the locale's
+     * region is often the most determinant factor). If a transition occurs at
+     * midnight, then the days before and after the transition will have the
      * type WEEKDAY or WEEKEND.  If a transition occurs at a time
      * other than midnight, then the day of the transition will have
      * the type WEEKEND_ONSET or WEEKEND_CEASE.  In this case, the
@@ -4387,6 +4388,11 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
         if (dayOfWeek < SUNDAY || dayOfWeek > SATURDAY) {
             throw new IllegalArgumentException("Invalid day of week");
         }
+        if (weekendOnset == weekendCease) {
+            if (dayOfWeek != weekendOnset)
+                return WEEKDAY;
+            return (weekendOnsetMillis == 0) ? WEEKEND : WEEKEND_ONSET;
+        }
         if (weekendOnset < weekendCease) {
             if (dayOfWeek < weekendOnset || dayOfWeek > weekendCease) {
                 return WEEKDAY;
@@ -4400,7 +4406,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
             return (weekendOnsetMillis == 0) ? WEEKEND : WEEKEND_ONSET;
         }
         if (dayOfWeek == weekendCease) {
-            return (weekendCeaseMillis == 0) ? WEEKDAY : WEEKEND_CEASE;
+            return (weekendCeaseMillis >= 86400000) ? WEEKEND : WEEKEND_CEASE;
         }
         return WEEKEND;
     }
index 9a1c80f1bcaf60900bde6019a7ad8d13fa9cbcaf..0ab78feb078c049eb71ea950d57c1918a579d6ec 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- * Copyright (C) 2000-2012, International Business Machines Corporation and
+ * Copyright (C) 2000-2013, International Business Machines Corporation and
  * others. All Rights Reserved.
  *******************************************************************************
  */
@@ -83,13 +83,19 @@ public class IBMCalendarTest extends CalendarTest {
                 Calendar.MONDAY,   Calendar.WEEKDAY,
                 Calendar.FRIDAY,   Calendar.WEEKDAY,
                 Calendar.SATURDAY, Calendar.WEEKEND,
-                Calendar.SUNDAY,   Calendar.WEEKEND_CEASE,
+                Calendar.SUNDAY,   Calendar.WEEKEND,
             },
             new Locale("ar", "YE"), new int[] { // Thursday:Friday
                 Calendar.WEDNESDAY,Calendar.WEEKDAY,
                 Calendar.SATURDAY, Calendar.WEEKDAY,
                 Calendar.THURSDAY, Calendar.WEEKEND,
-                Calendar.FRIDAY,   Calendar.WEEKEND_CEASE,
+                Calendar.FRIDAY,   Calendar.WEEKEND,
+            },
+            new Locale("hi", "IN"), new int[] { // Sunday only
+                Calendar.MONDAY,   Calendar.WEEKDAY,
+                Calendar.FRIDAY,   Calendar.WEEKDAY,
+                Calendar.SATURDAY, Calendar.WEEKDAY,
+                Calendar.SUNDAY,   Calendar.WEEKEND,
             },
         };