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