From 84e687333e646cc058a69bdb6da3063998e920eb Mon Sep 17 00:00:00 2001 From: Masayoshi Okutsu Date: Thu, 24 Feb 2011 15:09:21 +0900 Subject: [PATCH] 7021989: Missing observesDaylightTime override in ZoneInfo Reviewed-by: peytoia --- .../classes/sun/util/calendar/ZoneInfo.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java index 8bcf82ce760..7da1a6a7387 100644 --- a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java +++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java @@ -266,7 +266,7 @@ public class ZoneInfo extends TimeZone { 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 @@ public class ZoneInfo extends TimeZone { 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. */