Logo Search packages:      
Sourcecode: icu version File versions

tztrans.cpp

/*
*******************************************************************************
* Copyright (C) 2007-2010, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*/

#include <typeinfo>  // for 'typeid' to work

#include "unicode/utypes.h"

#if !UCONFIG_NO_FORMATTING

#include "unicode/tzrule.h"
#include "unicode/tztrans.h"

U_NAMESPACE_BEGIN

UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeZoneTransition)

00021 TimeZoneTransition::TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to)
: UObject(), fTime(time), fFrom(from.clone()), fTo(to.clone()) {
}

00025 TimeZoneTransition::TimeZoneTransition()
: UObject(), fTime(0), fFrom(NULL), fTo(NULL) {
}

00029 TimeZoneTransition::TimeZoneTransition(const TimeZoneTransition& source)
: UObject(), fTime(source.fTime), fFrom(NULL), fTo(NULL) {
      if (source.fFrom != NULL) {
          fFrom = source.fFrom->clone();
      }

      if (source.fTo != NULL) {
          fTo = source.fTo->clone();
      }
}

00040 TimeZoneTransition::~TimeZoneTransition() {
    if (fFrom != NULL) {
        delete fFrom;
    }
    if (fTo != NULL) {
        delete fTo;
    }
}

TimeZoneTransition*
00050 TimeZoneTransition::clone(void) const {
    return new TimeZoneTransition(*this);
}

TimeZoneTransition&
00055 TimeZoneTransition::operator=(const TimeZoneTransition& right) {
    if (this != &right) {
        fTime = right.fTime;
        setFrom(*right.fFrom);
        setTo(*right.fTo);
    }
    return *this;
}

UBool
00065 TimeZoneTransition::operator==(const TimeZoneTransition& that) const {
    if (this == &that) {
        return TRUE;
    }
    if (typeid(*this) != typeid(that)) {
        return FALSE;
    }
    if (fTime != that.fTime) {
        return FALSE;
    }
    if ((fFrom == NULL && that.fFrom == NULL)
        || (fFrom != NULL && that.fFrom != NULL && *fFrom == *(that.fFrom))) {
        if ((fTo == NULL && that.fTo == NULL)
            || (fTo != NULL && that.fTo != NULL && *fTo == *(that.fTo))) {
            return TRUE;
        }
    }
    return FALSE;
}

UBool
00086 TimeZoneTransition::operator!=(const TimeZoneTransition& that) const {
    return !operator==(that);
}

void
00091 TimeZoneTransition::setTime(UDate time) {
    fTime = time;
}

void
00096 TimeZoneTransition::setFrom(const TimeZoneRule& from) {
    if (fFrom != NULL) {
        delete fFrom;
    }
    fFrom = from.clone();
}

void
00104 TimeZoneTransition::adoptFrom(TimeZoneRule* from) {
    if (fFrom != NULL) {
        delete fFrom;
    }
    fFrom = from;
}

void
00112 TimeZoneTransition::setTo(const TimeZoneRule& to) {
    if (fTo != NULL) {
        delete fTo;
    }
    fTo = to.clone();
}

void
00120 TimeZoneTransition::adoptTo(TimeZoneRule* to) {
    if (fTo != NULL) {
        delete fTo;
    }
    fTo = to;
}

UDate
00128 TimeZoneTransition::getTime(void) const {
    return fTime;
}

const TimeZoneRule*
00133 TimeZoneTransition::getTo(void) const {
    return fTo;
}

const TimeZoneRule*
00138 TimeZoneTransition::getFrom(void) const {
    return fFrom;
}

U_NAMESPACE_END

#endif

//eof

Generated by  Doxygen 1.6.0   Back to index