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