/*
*******************************************************************************
- * 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
********************************************************************************
*/
+#include <typeinfo> // for 'typeid' to work
+
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
SimpleTimeZone::operator==(const TimeZone& that) const
{
return ((this == &that) ||
- (getDynamicClassID() == that.getDynamicClassID() &&
+ (typeid(*this) == typeid(that) &&
TimeZone::operator==(that) &&
hasSameRules(that)));
}
// 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;
}
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 &&
UBool
SimpleTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ {
- if (startMonth == 0) {
+ if (!useDaylight) {
return FALSE;
}
UBool
SimpleTimeZone::getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ {
- if (startMonth == 0) {
+ if (!useDaylight) {
return FALSE;
}
UnicodeString tzid;
getID(tzid);
- if (startMonth != 0) {
+ if (useDaylight) {
DateTimeRule* dtRule;
DateTimeRule::TimeRuleType timeRuleType;
UDate firstStdStart, firstDstStart;
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
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
// 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.
int32_t
SimpleTimeZone::countTransitionRules(UErrorCode& /*status*/) /*const*/ {
- return (startMonth == 0) ? 0 : 2;
+ return (useDaylight) ? 2 : 0;
}
void