| 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/vtzone.h" | 13 #include "unicode/vtzone.h" |
| 15 #include "unicode/rbtz.h" | 14 #include "unicode/rbtz.h" |
| 16 #include "unicode/ucal.h" | 15 #include "unicode/ucal.h" |
| 17 #include "unicode/ures.h" | 16 #include "unicode/ures.h" |
| 18 #include "cmemory.h" | 17 #include "cmemory.h" |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 icutzver = right.icutzver; | 1027 icutzver = right.icutzver; |
| 1029 } | 1028 } |
| 1030 return *this; | 1029 return *this; |
| 1031 } | 1030 } |
| 1032 | 1031 |
| 1033 UBool | 1032 UBool |
| 1034 VTimeZone::operator==(const TimeZone& that) const { | 1033 VTimeZone::operator==(const TimeZone& that) const { |
| 1035 if (this == &that) { | 1034 if (this == &that) { |
| 1036 return TRUE; | 1035 return TRUE; |
| 1037 } | 1036 } |
| 1038 if (typeid(*this) != typeid(that) || !BasicTimeZone::operator==(that)) { | 1037 if (CR_TYPEID(*this) != CR_TYPEID(that) || !BasicTimeZone::operator==(that))
{ |
| 1039 return FALSE; | 1038 return FALSE; |
| 1040 } | 1039 } |
| 1041 VTimeZone *vtz = (VTimeZone*)&that; | 1040 VTimeZone *vtz = (VTimeZone*)&that; |
| 1042 if (*tz == *(vtz->tz) | 1041 if (*tz == *(vtz->tz) |
| 1043 && tzurl == vtz->tzurl | 1042 && tzurl == vtz->tzurl |
| 1044 && lastmod == vtz->lastmod | 1043 && lastmod == vtz->lastmod |
| 1045 /* && olsonzid = that.olsonzid */ | 1044 /* && olsonzid = that.olsonzid */ |
| 1046 /* && icutzver = that.icutzver */) { | 1045 /* && icutzver = that.icutzver */) { |
| 1047 return TRUE; | 1046 return TRUE; |
| 1048 } | 1047 } |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 // Finally, create the RuleBasedTimeZone | 1587 // Finally, create the RuleBasedTimeZone |
| 1589 rbtz = new RuleBasedTimeZone(tzid, initialRule); | 1588 rbtz = new RuleBasedTimeZone(tzid, initialRule); |
| 1590 if (rbtz == NULL) { | 1589 if (rbtz == NULL) { |
| 1591 status = U_MEMORY_ALLOCATION_ERROR; | 1590 status = U_MEMORY_ALLOCATION_ERROR; |
| 1592 goto cleanupParse; | 1591 goto cleanupParse; |
| 1593 } | 1592 } |
| 1594 initialRule = NULL; // already adopted by RBTZ, no need to delete | 1593 initialRule = NULL; // already adopted by RBTZ, no need to delete |
| 1595 | 1594 |
| 1596 for (n = 0; n < rules->size(); n++) { | 1595 for (n = 0; n < rules->size(); n++) { |
| 1597 TimeZoneRule *r = (TimeZoneRule*)rules->elementAt(n); | 1596 TimeZoneRule *r = (TimeZoneRule*)rules->elementAt(n); |
| 1598 AnnualTimeZoneRule *atzrule = dynamic_cast<AnnualTimeZoneRule *>(r); | 1597 AnnualTimeZoneRule *atzrule = CR_DYNAMIC_CAST<AnnualTimeZoneRule *>(r); |
| 1599 if (atzrule != NULL) { | 1598 if (atzrule != NULL) { |
| 1600 if (atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR) { | 1599 if (atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR) { |
| 1601 finalRuleCount++; | 1600 finalRuleCount++; |
| 1602 finalRuleIdx = n; | 1601 finalRuleIdx = n; |
| 1603 } | 1602 } |
| 1604 } | 1603 } |
| 1605 } | 1604 } |
| 1606 if (finalRuleCount > 2) { | 1605 if (finalRuleCount > 2) { |
| 1607 // Too many final rules | 1606 // Too many final rules |
| 1608 status = U_ILLEGAL_ARGUMENT_ERROR; | 1607 status = U_ILLEGAL_ARGUMENT_ERROR; |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1949 isDst = (tzt.getTo()->getDSTSavings() != 0); | 1948 isDst = (tzt.getTo()->getDSTSavings() != 0); |
| 1950 int32_t fromOffset = tzt.getFrom()->getRawOffset() + tzt.getFrom()->getD
STSavings(); | 1949 int32_t fromOffset = tzt.getFrom()->getRawOffset() + tzt.getFrom()->getD
STSavings(); |
| 1951 int32_t fromDSTSavings = tzt.getFrom()->getDSTSavings(); | 1950 int32_t fromDSTSavings = tzt.getFrom()->getDSTSavings(); |
| 1952 int32_t toOffset = tzt.getTo()->getRawOffset() + tzt.getTo()->getDSTSavi
ngs(); | 1951 int32_t toOffset = tzt.getTo()->getRawOffset() + tzt.getTo()->getDSTSavi
ngs(); |
| 1953 Grego::timeToFields(tzt.getTime() + fromOffset, year, month, dom, dow, d
oy, mid); | 1952 Grego::timeToFields(tzt.getTime() + fromOffset, year, month, dom, dow, d
oy, mid); |
| 1954 int32_t weekInMonth = Grego::dayOfWeekInMonth(year, month, dom); | 1953 int32_t weekInMonth = Grego::dayOfWeekInMonth(year, month, dom); |
| 1955 UBool sameRule = FALSE; | 1954 UBool sameRule = FALSE; |
| 1956 const AnnualTimeZoneRule *atzrule; | 1955 const AnnualTimeZoneRule *atzrule; |
| 1957 if (isDst) { | 1956 if (isDst) { |
| 1958 if (finalDstRule == NULL | 1957 if (finalDstRule == NULL |
| 1959 && (atzrule = dynamic_cast<const AnnualTimeZoneRule *>(tzt.getTo
())) != NULL | 1958 && (atzrule = CR_DYNAMIC_CAST<const AnnualTimeZoneRule *>(tzt.ge
tTo())) != NULL |
| 1960 && atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR | 1959 && atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR |
| 1961 ) { | 1960 ) { |
| 1962 finalDstRule = (AnnualTimeZoneRule*)tzt.getTo()->clone(); | 1961 finalDstRule = (AnnualTimeZoneRule*)tzt.getTo()->clone(); |
| 1963 } | 1962 } |
| 1964 if (dstCount > 0) { | 1963 if (dstCount > 0) { |
| 1965 if (year == dstStartYear + dstCount | 1964 if (year == dstStartYear + dstCount |
| 1966 && name.compare(dstName) == 0 | 1965 && name.compare(dstName) == 0 |
| 1967 && dstFromOffset == fromOffset | 1966 && dstFromOffset == fromOffset |
| 1968 && dstToOffset == toOffset | 1967 && dstToOffset == toOffset |
| 1969 && dstMonth == month | 1968 && dstMonth == month |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2000 dstWeekInMonth = weekInMonth; | 1999 dstWeekInMonth = weekInMonth; |
| 2001 dstMillisInDay = mid; | 2000 dstMillisInDay = mid; |
| 2002 dstStartTime = dstUntilTime = t; | 2001 dstStartTime = dstUntilTime = t; |
| 2003 dstCount = 1; | 2002 dstCount = 1; |
| 2004 } | 2003 } |
| 2005 if (finalStdRule != NULL && finalDstRule != NULL) { | 2004 if (finalStdRule != NULL && finalDstRule != NULL) { |
| 2006 break; | 2005 break; |
| 2007 } | 2006 } |
| 2008 } else { | 2007 } else { |
| 2009 if (finalStdRule == NULL | 2008 if (finalStdRule == NULL |
| 2010 && (atzrule = dynamic_cast<const AnnualTimeZoneRule *>(tzt.getTo
())) != NULL | 2009 && (atzrule = CR_DYNAMIC_CAST<const AnnualTimeZoneRule *>(tzt.ge
tTo())) != NULL |
| 2011 && atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR | 2010 && atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR |
| 2012 ) { | 2011 ) { |
| 2013 finalStdRule = (AnnualTimeZoneRule*)tzt.getTo()->clone(); | 2012 finalStdRule = (AnnualTimeZoneRule*)tzt.getTo()->clone(); |
| 2014 } | 2013 } |
| 2015 if (stdCount > 0) { | 2014 if (stdCount > 0) { |
| 2016 if (year == stdStartYear + stdCount | 2015 if (year == stdStartYear + stdCount |
| 2017 && name.compare(stdName) == 0 | 2016 && name.compare(stdName) == 0 |
| 2018 && stdFromOffset == fromOffset | 2017 && stdFromOffset == fromOffset |
| 2019 && stdToOffset == toOffset | 2018 && stdToOffset == toOffset |
| 2020 && stdMonth == month | 2019 && stdMonth == month |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2616 writer.write(EQUALS_SIGN); | 2615 writer.write(EQUALS_SIGN); |
| 2617 writer.write(until); | 2616 writer.write(until); |
| 2618 } | 2617 } |
| 2619 } | 2618 } |
| 2620 | 2619 |
| 2621 U_NAMESPACE_END | 2620 U_NAMESPACE_END |
| 2622 | 2621 |
| 2623 #endif /* #if !UCONFIG_NO_FORMATTING */ | 2622 #endif /* #if !UCONFIG_NO_FORMATTING */ |
| 2624 | 2623 |
| 2625 //eof | 2624 //eof |
| OLD | NEW |