| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 2007-2010, International Business Machines Corporation and | 3 * Copyright (C) 2007-2010, International Business Machines Corporation and |
| 4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include <typeinfo> // for 'typeid' to work | |
| 9 | 8 |
| 10 #include "unicode/utypes.h" | 9 #include "unicode/utypes.h" |
| 11 | 10 |
| 12 #if !UCONFIG_NO_FORMATTING | 11 #if !UCONFIG_NO_FORMATTING |
| 13 | 12 |
| 14 #include "unicode/tzrule.h" | 13 #include "unicode/tzrule.h" |
| 15 #include "unicode/ucal.h" | 14 #include "unicode/ucal.h" |
| 16 #include "gregoimp.h" | 15 #include "gregoimp.h" |
| 17 #include "cmemory.h" | 16 #include "cmemory.h" |
| 18 #include "uarrsort.h" | 17 #include "uarrsort.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 47 fName = right.fName; | 46 fName = right.fName; |
| 48 fRawOffset = right.fRawOffset; | 47 fRawOffset = right.fRawOffset; |
| 49 fDSTSavings = right.fDSTSavings; | 48 fDSTSavings = right.fDSTSavings; |
| 50 } | 49 } |
| 51 return *this; | 50 return *this; |
| 52 } | 51 } |
| 53 | 52 |
| 54 UBool | 53 UBool |
| 55 TimeZoneRule::operator==(const TimeZoneRule& that) const { | 54 TimeZoneRule::operator==(const TimeZoneRule& that) const { |
| 56 return ((this == &that) || | 55 return ((this == &that) || |
| 57 (typeid(*this) == typeid(that) && | 56 (CR_TYPEID(*this) == CR_TYPEID(that) && |
| 58 fName == that.fName && | 57 fName == that.fName && |
| 59 fRawOffset == that.fRawOffset && | 58 fRawOffset == that.fRawOffset && |
| 60 fDSTSavings == that.fDSTSavings)); | 59 fDSTSavings == that.fDSTSavings)); |
| 61 } | 60 } |
| 62 | 61 |
| 63 UBool | 62 UBool |
| 64 TimeZoneRule::operator!=(const TimeZoneRule& that) const { | 63 TimeZoneRule::operator!=(const TimeZoneRule& that) const { |
| 65 return !operator==(that); | 64 return !operator==(that); |
| 66 } | 65 } |
| 67 | 66 |
| 68 UnicodeString& | 67 UnicodeString& |
| 69 TimeZoneRule::getName(UnicodeString& name) const { | 68 TimeZoneRule::getName(UnicodeString& name) const { |
| 70 name = fName; | 69 name = fName; |
| 71 return name; | 70 return name; |
| 72 } | 71 } |
| 73 | 72 |
| 74 int32_t | 73 int32_t |
| 75 TimeZoneRule::getRawOffset(void) const { | 74 TimeZoneRule::getRawOffset(void) const { |
| 76 return fRawOffset; | 75 return fRawOffset; |
| 77 } | 76 } |
| 78 | 77 |
| 79 int32_t | 78 int32_t |
| 80 TimeZoneRule::getDSTSavings(void) const { | 79 TimeZoneRule::getDSTSavings(void) const { |
| 81 return fDSTSavings; | 80 return fDSTSavings; |
| 82 } | 81 } |
| 83 | 82 |
| 84 UBool | 83 UBool |
| 85 TimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const { | 84 TimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const { |
| 86 return ((this == &other) || | 85 return ((this == &other) || |
| 87 (typeid(*this) == typeid(other) && | 86 (CR_TYPEID(*this) == CR_TYPEID(other) && |
| 88 fRawOffset == other.fRawOffset && | 87 fRawOffset == other.fRawOffset && |
| 89 fDSTSavings == other.fDSTSavings)); | 88 fDSTSavings == other.fDSTSavings)); |
| 90 } | 89 } |
| 91 | 90 |
| 92 | 91 |
| 93 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(InitialTimeZoneRule) | 92 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(InitialTimeZoneRule) |
| 94 | 93 |
| 95 InitialTimeZoneRule::InitialTimeZoneRule(const UnicodeString& name, | 94 InitialTimeZoneRule::InitialTimeZoneRule(const UnicodeString& name, |
| 96 int32_t rawOffset, | 95 int32_t rawOffset, |
| 97 int32_t dstSavings) | 96 int32_t dstSavings) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 114 InitialTimeZoneRule::operator=(const InitialTimeZoneRule& right) { | 113 InitialTimeZoneRule::operator=(const InitialTimeZoneRule& right) { |
| 115 if (this != &right) { | 114 if (this != &right) { |
| 116 TimeZoneRule::operator=(right); | 115 TimeZoneRule::operator=(right); |
| 117 } | 116 } |
| 118 return *this; | 117 return *this; |
| 119 } | 118 } |
| 120 | 119 |
| 121 UBool | 120 UBool |
| 122 InitialTimeZoneRule::operator==(const TimeZoneRule& that) const { | 121 InitialTimeZoneRule::operator==(const TimeZoneRule& that) const { |
| 123 return ((this == &that) || | 122 return ((this == &that) || |
| 124 (typeid(*this) == typeid(that) && | 123 (CR_TYPEID(*this) == CR_TYPEID(that) && |
| 125 TimeZoneRule::operator==(that))); | 124 TimeZoneRule::operator==(that))); |
| 126 } | 125 } |
| 127 | 126 |
| 128 UBool | 127 UBool |
| 129 InitialTimeZoneRule::operator!=(const TimeZoneRule& that) const { | 128 InitialTimeZoneRule::operator!=(const TimeZoneRule& that) const { |
| 130 return !operator==(that); | 129 return !operator==(that); |
| 131 } | 130 } |
| 132 | 131 |
| 133 UBool | 132 UBool |
| 134 InitialTimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const { | 133 InitialTimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const { |
| 135 if (this == &other) { | 134 if (this == &other) { |
| 136 return TRUE; | 135 return TRUE; |
| 137 } | 136 } |
| 138 if (typeid(*this) != typeid(other) || TimeZoneRule::isEquivalentTo(other) ==
FALSE) { | 137 if (CR_TYPEID(*this) != CR_TYPEID(other) || TimeZoneRule::isEquivalentTo(oth
er) == FALSE) { |
| 139 return FALSE; | 138 return FALSE; |
| 140 } | 139 } |
| 141 return TRUE; | 140 return TRUE; |
| 142 } | 141 } |
| 143 | 142 |
| 144 UBool | 143 UBool |
| 145 InitialTimeZoneRule::getFirstStart(int32_t /*prevRawOffset*/, | 144 InitialTimeZoneRule::getFirstStart(int32_t /*prevRawOffset*/, |
| 146 int32_t /*prevDSTSavings*/, | 145 int32_t /*prevDSTSavings*/, |
| 147 UDate& /*result*/) const { | 146 UDate& /*result*/) const { |
| 148 return FALSE; | 147 return FALSE; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 fEndYear = right.fEndYear; | 221 fEndYear = right.fEndYear; |
| 223 } | 222 } |
| 224 return *this; | 223 return *this; |
| 225 } | 224 } |
| 226 | 225 |
| 227 UBool | 226 UBool |
| 228 AnnualTimeZoneRule::operator==(const TimeZoneRule& that) const { | 227 AnnualTimeZoneRule::operator==(const TimeZoneRule& that) const { |
| 229 if (this == &that) { | 228 if (this == &that) { |
| 230 return TRUE; | 229 return TRUE; |
| 231 } | 230 } |
| 232 if (typeid(*this) != typeid(that)) { | 231 if (CR_TYPEID(*this) != CR_TYPEID(that)) { |
| 233 return FALSE; | 232 return FALSE; |
| 234 } | 233 } |
| 235 AnnualTimeZoneRule *atzr = (AnnualTimeZoneRule*)&that; | 234 AnnualTimeZoneRule *atzr = (AnnualTimeZoneRule*)&that; |
| 236 return (*fDateTimeRule == *(atzr->fDateTimeRule) && | 235 return (*fDateTimeRule == *(atzr->fDateTimeRule) && |
| 237 fStartYear == atzr->fStartYear && | 236 fStartYear == atzr->fStartYear && |
| 238 fEndYear == atzr->fEndYear); | 237 fEndYear == atzr->fEndYear); |
| 239 } | 238 } |
| 240 | 239 |
| 241 UBool | 240 UBool |
| 242 AnnualTimeZoneRule::operator!=(const TimeZoneRule& that) const { | 241 AnnualTimeZoneRule::operator!=(const TimeZoneRule& that) const { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 result -= prevDSTSavings; | 313 result -= prevDSTSavings; |
| 315 } | 314 } |
| 316 return TRUE; | 315 return TRUE; |
| 317 } | 316 } |
| 318 | 317 |
| 319 UBool | 318 UBool |
| 320 AnnualTimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const { | 319 AnnualTimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const { |
| 321 if (this == &other) { | 320 if (this == &other) { |
| 322 return TRUE; | 321 return TRUE; |
| 323 } | 322 } |
| 324 if (typeid(*this) != typeid(other) || TimeZoneRule::isEquivalentTo(other) ==
FALSE) { | 323 if (CR_TYPEID(*this) != CR_TYPEID(other) || TimeZoneRule::isEquivalentTo(oth
er) == FALSE) { |
| 325 return FALSE; | 324 return FALSE; |
| 326 } | 325 } |
| 327 AnnualTimeZoneRule* that = (AnnualTimeZoneRule*)&other; | 326 AnnualTimeZoneRule* that = (AnnualTimeZoneRule*)&other; |
| 328 return (*fDateTimeRule == *(that->fDateTimeRule) && | 327 return (*fDateTimeRule == *(that->fDateTimeRule) && |
| 329 fStartYear == that->fStartYear && | 328 fStartYear == that->fStartYear && |
| 330 fEndYear == that->fEndYear); | 329 fEndYear == that->fEndYear); |
| 331 } | 330 } |
| 332 | 331 |
| 333 UBool | 332 UBool |
| 334 AnnualTimeZoneRule::getFirstStart(int32_t prevRawOffset, | 333 AnnualTimeZoneRule::getFirstStart(int32_t prevRawOffset, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 fTimeRuleType = right.fTimeRuleType; | 440 fTimeRuleType = right.fTimeRuleType; |
| 442 } | 441 } |
| 443 return *this; | 442 return *this; |
| 444 } | 443 } |
| 445 | 444 |
| 446 UBool | 445 UBool |
| 447 TimeArrayTimeZoneRule::operator==(const TimeZoneRule& that) const { | 446 TimeArrayTimeZoneRule::operator==(const TimeZoneRule& that) const { |
| 448 if (this == &that) { | 447 if (this == &that) { |
| 449 return TRUE; | 448 return TRUE; |
| 450 } | 449 } |
| 451 if (typeid(*this) != typeid(that) || TimeZoneRule::operator==(that) == FALSE
) { | 450 if (CR_TYPEID(*this) != CR_TYPEID(that) || TimeZoneRule::operator==(that) ==
FALSE) { |
| 452 return FALSE; | 451 return FALSE; |
| 453 } | 452 } |
| 454 TimeArrayTimeZoneRule *tatzr = (TimeArrayTimeZoneRule*)&that; | 453 TimeArrayTimeZoneRule *tatzr = (TimeArrayTimeZoneRule*)&that; |
| 455 if (fTimeRuleType != tatzr->fTimeRuleType || | 454 if (fTimeRuleType != tatzr->fTimeRuleType || |
| 456 fNumStartTimes != tatzr->fNumStartTimes) { | 455 fNumStartTimes != tatzr->fNumStartTimes) { |
| 457 return FALSE; | 456 return FALSE; |
| 458 } | 457 } |
| 459 // Compare start times | 458 // Compare start times |
| 460 UBool res = TRUE; | 459 UBool res = TRUE; |
| 461 for (int32_t i = 0; i < fNumStartTimes; i++) { | 460 for (int32_t i = 0; i < fNumStartTimes; i++) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 489 int32_t | 488 int32_t |
| 490 TimeArrayTimeZoneRule::countStartTimes(void) const { | 489 TimeArrayTimeZoneRule::countStartTimes(void) const { |
| 491 return fNumStartTimes; | 490 return fNumStartTimes; |
| 492 } | 491 } |
| 493 | 492 |
| 494 UBool | 493 UBool |
| 495 TimeArrayTimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const { | 494 TimeArrayTimeZoneRule::isEquivalentTo(const TimeZoneRule& other) const { |
| 496 if (this == &other) { | 495 if (this == &other) { |
| 497 return TRUE; | 496 return TRUE; |
| 498 } | 497 } |
| 499 if (typeid(*this) != typeid(other) || TimeZoneRule::isEquivalentTo(other) ==
FALSE) { | 498 if (CR_TYPEID(*this) != CR_TYPEID(other) || TimeZoneRule::isEquivalentTo(oth
er) == FALSE) { |
| 500 return FALSE; | 499 return FALSE; |
| 501 } | 500 } |
| 502 TimeArrayTimeZoneRule* that = (TimeArrayTimeZoneRule*)&other; | 501 TimeArrayTimeZoneRule* that = (TimeArrayTimeZoneRule*)&other; |
| 503 if (fTimeRuleType != that->fTimeRuleType || | 502 if (fTimeRuleType != that->fTimeRuleType || |
| 504 fNumStartTimes != that->fNumStartTimes) { | 503 fNumStartTimes != that->fNumStartTimes) { |
| 505 return FALSE; | 504 return FALSE; |
| 506 } | 505 } |
| 507 // Compare start times | 506 // Compare start times |
| 508 UBool res = TRUE; | 507 UBool res = TRUE; |
| 509 for (int32_t i = 0; i < fNumStartTimes; i++) { | 508 for (int32_t i = 0; i < fNumStartTimes; i++) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 } | 617 } |
| 619 return time; | 618 return time; |
| 620 } | 619 } |
| 621 | 620 |
| 622 U_NAMESPACE_END | 621 U_NAMESPACE_END |
| 623 | 622 |
| 624 #endif /* #if !UCONFIG_NO_FORMATTING */ | 623 #endif /* #if !UCONFIG_NO_FORMATTING */ |
| 625 | 624 |
| 626 //eof | 625 //eof |
| 627 | 626 |
| OLD | NEW |