michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2007-2012, International Business Machines Corporation and michael@0: * others. All Rights Reserved. michael@0: ******************************************************************************* michael@0: */ michael@0: michael@0: #include "utypeinfo.h" // for 'typeid' to work michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/tzrule.h" michael@0: #include "unicode/tztrans.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeZoneTransition) michael@0: michael@0: TimeZoneTransition::TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to) michael@0: : UObject(), fTime(time), fFrom(from.clone()), fTo(to.clone()) { michael@0: } michael@0: michael@0: TimeZoneTransition::TimeZoneTransition() michael@0: : UObject(), fTime(0), fFrom(NULL), fTo(NULL) { michael@0: } michael@0: michael@0: TimeZoneTransition::TimeZoneTransition(const TimeZoneTransition& source) michael@0: : UObject(), fTime(source.fTime), fFrom(NULL), fTo(NULL) { michael@0: if (source.fFrom != NULL) { michael@0: fFrom = source.fFrom->clone(); michael@0: } michael@0: michael@0: if (source.fTo != NULL) { michael@0: fTo = source.fTo->clone(); michael@0: } michael@0: } michael@0: michael@0: TimeZoneTransition::~TimeZoneTransition() { michael@0: if (fFrom != NULL) { michael@0: delete fFrom; michael@0: } michael@0: if (fTo != NULL) { michael@0: delete fTo; michael@0: } michael@0: } michael@0: michael@0: TimeZoneTransition* michael@0: TimeZoneTransition::clone(void) const { michael@0: return new TimeZoneTransition(*this); michael@0: } michael@0: michael@0: TimeZoneTransition& michael@0: TimeZoneTransition::operator=(const TimeZoneTransition& right) { michael@0: if (this != &right) { michael@0: fTime = right.fTime; michael@0: setFrom(*right.fFrom); michael@0: setTo(*right.fTo); michael@0: } michael@0: return *this; michael@0: } michael@0: michael@0: UBool michael@0: TimeZoneTransition::operator==(const TimeZoneTransition& that) const { michael@0: if (this == &that) { michael@0: return TRUE; michael@0: } michael@0: if (typeid(*this) != typeid(that)) { michael@0: return FALSE; michael@0: } michael@0: if (fTime != that.fTime) { michael@0: return FALSE; michael@0: } michael@0: if ((fFrom == NULL && that.fFrom == NULL) michael@0: || (fFrom != NULL && that.fFrom != NULL && *fFrom == *(that.fFrom))) { michael@0: if ((fTo == NULL && that.fTo == NULL) michael@0: || (fTo != NULL && that.fTo != NULL && *fTo == *(that.fTo))) { michael@0: return TRUE; michael@0: } michael@0: } michael@0: return FALSE; michael@0: } michael@0: michael@0: UBool michael@0: TimeZoneTransition::operator!=(const TimeZoneTransition& that) const { michael@0: return !operator==(that); michael@0: } michael@0: michael@0: void michael@0: TimeZoneTransition::setTime(UDate time) { michael@0: fTime = time; michael@0: } michael@0: michael@0: void michael@0: TimeZoneTransition::setFrom(const TimeZoneRule& from) { michael@0: if (fFrom != NULL) { michael@0: delete fFrom; michael@0: } michael@0: fFrom = from.clone(); michael@0: } michael@0: michael@0: void michael@0: TimeZoneTransition::adoptFrom(TimeZoneRule* from) { michael@0: if (fFrom != NULL) { michael@0: delete fFrom; michael@0: } michael@0: fFrom = from; michael@0: } michael@0: michael@0: void michael@0: TimeZoneTransition::setTo(const TimeZoneRule& to) { michael@0: if (fTo != NULL) { michael@0: delete fTo; michael@0: } michael@0: fTo = to.clone(); michael@0: } michael@0: michael@0: void michael@0: TimeZoneTransition::adoptTo(TimeZoneRule* to) { michael@0: if (fTo != NULL) { michael@0: delete fTo; michael@0: } michael@0: fTo = to; michael@0: } michael@0: michael@0: UDate michael@0: TimeZoneTransition::getTime(void) const { michael@0: return fTime; michael@0: } michael@0: michael@0: const TimeZoneRule* michael@0: TimeZoneTransition::getTo(void) const { michael@0: return fTo; michael@0: } michael@0: michael@0: const TimeZoneRule* michael@0: TimeZoneTransition::getFrom(void) const { michael@0: return fFrom; michael@0: } michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif michael@0: michael@0: //eof