]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/simpletz.cpp
ICU-491.11.1.tar.gz
[apple/icu.git] / icuSources / i18n / simpletz.cpp
index 42ed20531bfe2e13d2d2a5ba5c5df1bd174712b7..f04f85f0dbbf9c8d15d6b32ed0dc87c753effb49 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
- * Copyright (C) 1997-2008, International Business Machines Corporation and    *
- * others. All Rights Reserved.                                                *
+ * Copyright (C) 1997-2011, International Business Machines Corporation and
+ * others. All Rights Reserved.
  *******************************************************************************
  *
  * File SIMPLETZ.H
@@ -21,6 +21,8 @@
  ********************************************************************************
  */
 
+#include <typeinfo>  // for 'typeid' to work
+
 #include "unicode/utypes.h"
 
 #if !UCONFIG_NO_FORMATTING
@@ -229,7 +231,7 @@ UBool
 SimpleTimeZone::operator==(const TimeZone& that) const
 {
     return ((this == &that) ||
-            (getDynamicClassID() == that.getDynamicClassID() &&
+            (typeid(*this) == typeid(that) &&
             TimeZone::operator==(that) &&
             hasSameRules(that)));
 }
@@ -529,13 +531,13 @@ SimpleTimeZone::getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32
     // Now we need some adjustment
     if (savingsDST > 0) {
         if ((nonExistingTimeOpt & kStdDstMask) == kStandard
-            || (nonExistingTimeOpt & kStdDstMask) != kDaylight && (nonExistingTimeOpt & kFormerLatterMask) != kLatter) {
+            || ((nonExistingTimeOpt & kStdDstMask) != kDaylight && (nonExistingTimeOpt & kFormerLatterMask) != kLatter)) {
             date -= getDSTSavings();
             recalc = TRUE;
         }
     } else {
         if ((duplicatedTimeOpt & kStdDstMask) == kDaylight
-                || (duplicatedTimeOpt & kStdDstMask) != kStandard && (duplicatedTimeOpt & kFormerLatterMask) == kFormer) {
+                || ((duplicatedTimeOpt & kStdDstMask) != kStandard && (duplicatedTimeOpt & kFormerLatterMask) == kFormer)) {
             date -= getDSTSavings();
             recalc = TRUE;
         }
@@ -741,7 +743,7 @@ UBool
 SimpleTimeZone::hasSameRules(const TimeZone& other) const
 {
     if (this == &other) return TRUE;
-    if (other.getDynamicClassID() != SimpleTimeZone::getStaticClassID()) return FALSE;
+    if (typeid(*this) != typeid(other)) return FALSE;
     SimpleTimeZone *that = (SimpleTimeZone*)&other;
     return rawOffset     == that->rawOffset &&
         useDaylight     == that->useDaylight &&
@@ -966,7 +968,7 @@ SimpleTimeZone::decodeEndRule(UErrorCode& status)
 
 UBool
 SimpleTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ {
-    if (startMonth == 0) {
+    if (!useDaylight) {
         return FALSE;
     }
 
@@ -1000,7 +1002,7 @@ SimpleTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransitio
 
 UBool
 SimpleTimeZone::getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ {
-    if (startMonth == 0) {
+    if (!useDaylight) {
         return FALSE;
     }
 
@@ -1070,7 +1072,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
     UnicodeString tzid;
     getID(tzid);
 
-    if (startMonth != 0) {
+    if (useDaylight) {
         DateTimeRule* dtRule;
         DateTimeRule::TimeRuleType timeRuleType;
         UDate firstStdStart, firstDstStart;
@@ -1101,7 +1103,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
                return;
         }
         // For now, use ID + "(DST)" as the name
-        dstRule = new AnnualTimeZoneRule(tzid+DST_STR, getRawOffset(), getDSTSavings(),
+        dstRule = new AnnualTimeZoneRule(tzid+UnicodeString(DST_STR), getRawOffset(), getDSTSavings(),
             dtRule, startYear, AnnualTimeZoneRule::MAX_YEAR);
         
         // Check for Null pointer
@@ -1139,7 +1141,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
                return;
         }
         // For now, use ID + "(STD)" as the name
-        stdRule = new AnnualTimeZoneRule(tzid+STD_STR, getRawOffset(), 0,
+        stdRule = new AnnualTimeZoneRule(tzid+UnicodeString(STD_STR), getRawOffset(), 0,
             dtRule, startYear, AnnualTimeZoneRule::MAX_YEAR);
         
         //Check for Null pointer
@@ -1154,10 +1156,10 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
 
         // Create a TimeZoneRule for initial time
         if (firstStdStart < firstDstStart) {
-            initialRule = new InitialTimeZoneRule(tzid+DST_STR, getRawOffset(), dstRule->getDSTSavings());
+            initialRule = new InitialTimeZoneRule(tzid+UnicodeString(DST_STR), getRawOffset(), dstRule->getDSTSavings());
             firstTransition = new TimeZoneTransition(firstStdStart, *initialRule, *stdRule);
         } else {
-            initialRule = new InitialTimeZoneRule(tzid+STD_STR, getRawOffset(), 0);
+            initialRule = new InitialTimeZoneRule(tzid+UnicodeString(STD_STR), getRawOffset(), 0);
             firstTransition = new TimeZoneTransition(firstDstStart, *initialRule, *dstRule);
         }
         // Check for null pointers.
@@ -1183,7 +1185,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
 
 int32_t
 SimpleTimeZone::countTransitionRules(UErrorCode& /*status*/) /*const*/ {
-    return (startMonth == 0) ? 0 : 2;
+    return (useDaylight) ? 2 : 0;
 }
 
 void