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