7021989: Missing observesDaylightTime override in ZoneInfo
authorokutsu
Thu, 24 Feb 2011 15:09:21 +0900
changeset 8522 281cf853ef7a
parent 8521 ab64b8d109b8
child 8523 864a651f7b53
7021989: Missing observesDaylightTime override in ZoneInfo Reviewed-by: peytoia
jdk/src/share/classes/sun/util/calendar/ZoneInfo.java
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java	Wed Feb 23 16:50:13 2011 +0900
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java	Thu Feb 24 15:09:21 2011 +0900
@@ -266,7 +266,7 @@
         int index = getTransitionIndex(date, type);
 
         // prior to the transition table, returns the raw offset.
-        // should support LMT.
+        // FIXME: should support LMT.
         if (index < 0) {
             int offset = getLastRawOffset();
             if (offsets != null) {
@@ -452,6 +452,36 @@
         return (simpleTimeZoneParams != null);
     }
 
+    @Override
+    public boolean observesDaylightTime() {
+        if (simpleTimeZoneParams != null) {
+            return true;
+        }
+        if (transitions == null) {
+            return false;
+        }
+
+        // Look up the transition table to see if it's in DST right
+        // now or if there's any standard-to-daylight transition at
+        // any future.
+        long utc = System.currentTimeMillis() - rawOffsetDiff;
+        int index = getTransitionIndex(utc, UTC_TIME);
+
+        // before transitions in the transition table
+        if (index < 0) {
+            return false;
+        }
+
+        // the time is in the table range.
+        for (int i = index; i < transitions.length; i++) {
+            if ((transitions[i] & DST_MASK) != 0) {
+                return true;
+            }
+        }
+        // No further DST is observed.
+        return false;
+    }
+
     /**
      * Queries if the specified date is in Daylight Saving Time.
      */