intl/icu/source/i18n/tztrans.cpp

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 * Copyright (C) 2007-2012, International Business Machines Corporation and
michael@0 4 * others. All Rights Reserved.
michael@0 5 *******************************************************************************
michael@0 6 */
michael@0 7
michael@0 8 #include "utypeinfo.h" // for 'typeid' to work
michael@0 9
michael@0 10 #include "unicode/utypes.h"
michael@0 11
michael@0 12 #if !UCONFIG_NO_FORMATTING
michael@0 13
michael@0 14 #include "unicode/tzrule.h"
michael@0 15 #include "unicode/tztrans.h"
michael@0 16
michael@0 17 U_NAMESPACE_BEGIN
michael@0 18
michael@0 19 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeZoneTransition)
michael@0 20
michael@0 21 TimeZoneTransition::TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to)
michael@0 22 : UObject(), fTime(time), fFrom(from.clone()), fTo(to.clone()) {
michael@0 23 }
michael@0 24
michael@0 25 TimeZoneTransition::TimeZoneTransition()
michael@0 26 : UObject(), fTime(0), fFrom(NULL), fTo(NULL) {
michael@0 27 }
michael@0 28
michael@0 29 TimeZoneTransition::TimeZoneTransition(const TimeZoneTransition& source)
michael@0 30 : UObject(), fTime(source.fTime), fFrom(NULL), fTo(NULL) {
michael@0 31 if (source.fFrom != NULL) {
michael@0 32 fFrom = source.fFrom->clone();
michael@0 33 }
michael@0 34
michael@0 35 if (source.fTo != NULL) {
michael@0 36 fTo = source.fTo->clone();
michael@0 37 }
michael@0 38 }
michael@0 39
michael@0 40 TimeZoneTransition::~TimeZoneTransition() {
michael@0 41 if (fFrom != NULL) {
michael@0 42 delete fFrom;
michael@0 43 }
michael@0 44 if (fTo != NULL) {
michael@0 45 delete fTo;
michael@0 46 }
michael@0 47 }
michael@0 48
michael@0 49 TimeZoneTransition*
michael@0 50 TimeZoneTransition::clone(void) const {
michael@0 51 return new TimeZoneTransition(*this);
michael@0 52 }
michael@0 53
michael@0 54 TimeZoneTransition&
michael@0 55 TimeZoneTransition::operator=(const TimeZoneTransition& right) {
michael@0 56 if (this != &right) {
michael@0 57 fTime = right.fTime;
michael@0 58 setFrom(*right.fFrom);
michael@0 59 setTo(*right.fTo);
michael@0 60 }
michael@0 61 return *this;
michael@0 62 }
michael@0 63
michael@0 64 UBool
michael@0 65 TimeZoneTransition::operator==(const TimeZoneTransition& that) const {
michael@0 66 if (this == &that) {
michael@0 67 return TRUE;
michael@0 68 }
michael@0 69 if (typeid(*this) != typeid(that)) {
michael@0 70 return FALSE;
michael@0 71 }
michael@0 72 if (fTime != that.fTime) {
michael@0 73 return FALSE;
michael@0 74 }
michael@0 75 if ((fFrom == NULL && that.fFrom == NULL)
michael@0 76 || (fFrom != NULL && that.fFrom != NULL && *fFrom == *(that.fFrom))) {
michael@0 77 if ((fTo == NULL && that.fTo == NULL)
michael@0 78 || (fTo != NULL && that.fTo != NULL && *fTo == *(that.fTo))) {
michael@0 79 return TRUE;
michael@0 80 }
michael@0 81 }
michael@0 82 return FALSE;
michael@0 83 }
michael@0 84
michael@0 85 UBool
michael@0 86 TimeZoneTransition::operator!=(const TimeZoneTransition& that) const {
michael@0 87 return !operator==(that);
michael@0 88 }
michael@0 89
michael@0 90 void
michael@0 91 TimeZoneTransition::setTime(UDate time) {
michael@0 92 fTime = time;
michael@0 93 }
michael@0 94
michael@0 95 void
michael@0 96 TimeZoneTransition::setFrom(const TimeZoneRule& from) {
michael@0 97 if (fFrom != NULL) {
michael@0 98 delete fFrom;
michael@0 99 }
michael@0 100 fFrom = from.clone();
michael@0 101 }
michael@0 102
michael@0 103 void
michael@0 104 TimeZoneTransition::adoptFrom(TimeZoneRule* from) {
michael@0 105 if (fFrom != NULL) {
michael@0 106 delete fFrom;
michael@0 107 }
michael@0 108 fFrom = from;
michael@0 109 }
michael@0 110
michael@0 111 void
michael@0 112 TimeZoneTransition::setTo(const TimeZoneRule& to) {
michael@0 113 if (fTo != NULL) {
michael@0 114 delete fTo;
michael@0 115 }
michael@0 116 fTo = to.clone();
michael@0 117 }
michael@0 118
michael@0 119 void
michael@0 120 TimeZoneTransition::adoptTo(TimeZoneRule* to) {
michael@0 121 if (fTo != NULL) {
michael@0 122 delete fTo;
michael@0 123 }
michael@0 124 fTo = to;
michael@0 125 }
michael@0 126
michael@0 127 UDate
michael@0 128 TimeZoneTransition::getTime(void) const {
michael@0 129 return fTime;
michael@0 130 }
michael@0 131
michael@0 132 const TimeZoneRule*
michael@0 133 TimeZoneTransition::getTo(void) const {
michael@0 134 return fTo;
michael@0 135 }
michael@0 136
michael@0 137 const TimeZoneRule*
michael@0 138 TimeZoneTransition::getFrom(void) const {
michael@0 139 return fFrom;
michael@0 140 }
michael@0 141
michael@0 142 U_NAMESPACE_END
michael@0 143
michael@0 144 #endif
michael@0 145
michael@0 146 //eof

mercurial