1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2007-2012, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 *******************************************************************************
10 #include "utypeinfo.h" // for 'typeid' to work
12 #include "unicode/utypes.h"
14 #if !UCONFIG_NO_FORMATTING
16 #include "unicode/tzrule.h"
17 #include "unicode/tztrans.h"
21 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeZoneTransition)
23 TimeZoneTransition::TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to)
24 : UObject(), fTime(time), fFrom(from.clone()), fTo(to.clone()) {
27 TimeZoneTransition::TimeZoneTransition()
28 : UObject(), fTime(0), fFrom(NULL), fTo(NULL) {
31 TimeZoneTransition::TimeZoneTransition(const TimeZoneTransition& source)
32 : UObject(), fTime(source.fTime), fFrom(NULL), fTo(NULL) {
33 if (source.fFrom != NULL) {
34 fFrom = source.fFrom->clone();
37 if (source.fTo != NULL) {
38 fTo = source.fTo->clone();
42 TimeZoneTransition::~TimeZoneTransition() {
52 TimeZoneTransition::clone(void) const {
53 return new TimeZoneTransition(*this);
57 TimeZoneTransition::operator=(const TimeZoneTransition& right) {
60 setFrom(*right.fFrom);
67 TimeZoneTransition::operator==(const TimeZoneTransition& that) const {
71 if (typeid(*this) != typeid(that)) {
74 if (fTime != that.fTime) {
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))) {
88 TimeZoneTransition::operator!=(const TimeZoneTransition& that) const {
89 return !operator==(that);
93 TimeZoneTransition::setTime(UDate time) {
98 TimeZoneTransition::setFrom(const TimeZoneRule& from) {
102 fFrom = from.clone();
106 TimeZoneTransition::adoptFrom(TimeZoneRule* from) {
114 TimeZoneTransition::setTo(const TimeZoneRule& to) {
122 TimeZoneTransition::adoptTo(TimeZoneRule* to) {
130 TimeZoneTransition::getTime(void) const {
135 TimeZoneTransition::getTo(void) const {
140 TimeZoneTransition::getFrom(void) const {