1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/tztrans.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,146 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* Copyright (C) 2007-2012, International Business Machines Corporation and 1.7 +* others. All Rights Reserved. 1.8 +******************************************************************************* 1.9 +*/ 1.10 + 1.11 +#include "utypeinfo.h" // for 'typeid' to work 1.12 + 1.13 +#include "unicode/utypes.h" 1.14 + 1.15 +#if !UCONFIG_NO_FORMATTING 1.16 + 1.17 +#include "unicode/tzrule.h" 1.18 +#include "unicode/tztrans.h" 1.19 + 1.20 +U_NAMESPACE_BEGIN 1.21 + 1.22 +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeZoneTransition) 1.23 + 1.24 +TimeZoneTransition::TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to) 1.25 +: UObject(), fTime(time), fFrom(from.clone()), fTo(to.clone()) { 1.26 +} 1.27 + 1.28 +TimeZoneTransition::TimeZoneTransition() 1.29 +: UObject(), fTime(0), fFrom(NULL), fTo(NULL) { 1.30 +} 1.31 + 1.32 +TimeZoneTransition::TimeZoneTransition(const TimeZoneTransition& source) 1.33 +: UObject(), fTime(source.fTime), fFrom(NULL), fTo(NULL) { 1.34 + if (source.fFrom != NULL) { 1.35 + fFrom = source.fFrom->clone(); 1.36 + } 1.37 + 1.38 + if (source.fTo != NULL) { 1.39 + fTo = source.fTo->clone(); 1.40 + } 1.41 +} 1.42 + 1.43 +TimeZoneTransition::~TimeZoneTransition() { 1.44 + if (fFrom != NULL) { 1.45 + delete fFrom; 1.46 + } 1.47 + if (fTo != NULL) { 1.48 + delete fTo; 1.49 + } 1.50 +} 1.51 + 1.52 +TimeZoneTransition* 1.53 +TimeZoneTransition::clone(void) const { 1.54 + return new TimeZoneTransition(*this); 1.55 +} 1.56 + 1.57 +TimeZoneTransition& 1.58 +TimeZoneTransition::operator=(const TimeZoneTransition& right) { 1.59 + if (this != &right) { 1.60 + fTime = right.fTime; 1.61 + setFrom(*right.fFrom); 1.62 + setTo(*right.fTo); 1.63 + } 1.64 + return *this; 1.65 +} 1.66 + 1.67 +UBool 1.68 +TimeZoneTransition::operator==(const TimeZoneTransition& that) const { 1.69 + if (this == &that) { 1.70 + return TRUE; 1.71 + } 1.72 + if (typeid(*this) != typeid(that)) { 1.73 + return FALSE; 1.74 + } 1.75 + if (fTime != that.fTime) { 1.76 + return FALSE; 1.77 + } 1.78 + if ((fFrom == NULL && that.fFrom == NULL) 1.79 + || (fFrom != NULL && that.fFrom != NULL && *fFrom == *(that.fFrom))) { 1.80 + if ((fTo == NULL && that.fTo == NULL) 1.81 + || (fTo != NULL && that.fTo != NULL && *fTo == *(that.fTo))) { 1.82 + return TRUE; 1.83 + } 1.84 + } 1.85 + return FALSE; 1.86 +} 1.87 + 1.88 +UBool 1.89 +TimeZoneTransition::operator!=(const TimeZoneTransition& that) const { 1.90 + return !operator==(that); 1.91 +} 1.92 + 1.93 +void 1.94 +TimeZoneTransition::setTime(UDate time) { 1.95 + fTime = time; 1.96 +} 1.97 + 1.98 +void 1.99 +TimeZoneTransition::setFrom(const TimeZoneRule& from) { 1.100 + if (fFrom != NULL) { 1.101 + delete fFrom; 1.102 + } 1.103 + fFrom = from.clone(); 1.104 +} 1.105 + 1.106 +void 1.107 +TimeZoneTransition::adoptFrom(TimeZoneRule* from) { 1.108 + if (fFrom != NULL) { 1.109 + delete fFrom; 1.110 + } 1.111 + fFrom = from; 1.112 +} 1.113 + 1.114 +void 1.115 +TimeZoneTransition::setTo(const TimeZoneRule& to) { 1.116 + if (fTo != NULL) { 1.117 + delete fTo; 1.118 + } 1.119 + fTo = to.clone(); 1.120 +} 1.121 + 1.122 +void 1.123 +TimeZoneTransition::adoptTo(TimeZoneRule* to) { 1.124 + if (fTo != NULL) { 1.125 + delete fTo; 1.126 + } 1.127 + fTo = to; 1.128 +} 1.129 + 1.130 +UDate 1.131 +TimeZoneTransition::getTime(void) const { 1.132 + return fTime; 1.133 +} 1.134 + 1.135 +const TimeZoneRule* 1.136 +TimeZoneTransition::getTo(void) const { 1.137 + return fTo; 1.138 +} 1.139 + 1.140 +const TimeZoneRule* 1.141 +TimeZoneTransition::getFrom(void) const { 1.142 + return fFrom; 1.143 +} 1.144 + 1.145 +U_NAMESPACE_END 1.146 + 1.147 +#endif 1.148 + 1.149 +//eof