intl/icu/source/i18n/tztrans.cpp

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /*
     2 *******************************************************************************
     3 * Copyright (C) 2007-2012, International Business Machines Corporation and
     4 * others. All Rights Reserved.
     5 *******************************************************************************
     6 */
     8 #include "utypeinfo.h"  // for 'typeid' to work
    10 #include "unicode/utypes.h"
    12 #if !UCONFIG_NO_FORMATTING
    14 #include "unicode/tzrule.h"
    15 #include "unicode/tztrans.h"
    17 U_NAMESPACE_BEGIN
    19 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeZoneTransition)
    21 TimeZoneTransition::TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to)
    22 : UObject(), fTime(time), fFrom(from.clone()), fTo(to.clone()) {
    23 }
    25 TimeZoneTransition::TimeZoneTransition()
    26 : UObject(), fTime(0), fFrom(NULL), fTo(NULL) {
    27 }
    29 TimeZoneTransition::TimeZoneTransition(const TimeZoneTransition& source)
    30 : UObject(), fTime(source.fTime), fFrom(NULL), fTo(NULL) {
    31       if (source.fFrom != NULL) {
    32           fFrom = source.fFrom->clone();
    33       }
    35       if (source.fTo != NULL) {
    36           fTo = source.fTo->clone();
    37       }
    38 }
    40 TimeZoneTransition::~TimeZoneTransition() {
    41     if (fFrom != NULL) {
    42         delete fFrom;
    43     }
    44     if (fTo != NULL) {
    45         delete fTo;
    46     }
    47 }
    49 TimeZoneTransition*
    50 TimeZoneTransition::clone(void) const {
    51     return new TimeZoneTransition(*this);
    52 }
    54 TimeZoneTransition&
    55 TimeZoneTransition::operator=(const TimeZoneTransition& right) {
    56     if (this != &right) {
    57         fTime = right.fTime;
    58         setFrom(*right.fFrom);
    59         setTo(*right.fTo);
    60     }
    61     return *this;
    62 }
    64 UBool
    65 TimeZoneTransition::operator==(const TimeZoneTransition& that) const {
    66     if (this == &that) {
    67         return TRUE;
    68     }
    69     if (typeid(*this) != typeid(that)) {
    70         return FALSE;
    71     }
    72     if (fTime != that.fTime) {
    73         return FALSE;
    74     }
    75     if ((fFrom == NULL && that.fFrom == NULL)
    76         || (fFrom != NULL && that.fFrom != NULL && *fFrom == *(that.fFrom))) {
    77         if ((fTo == NULL && that.fTo == NULL)
    78             || (fTo != NULL && that.fTo != NULL && *fTo == *(that.fTo))) {
    79             return TRUE;
    80         }
    81     }
    82     return FALSE;
    83 }
    85 UBool
    86 TimeZoneTransition::operator!=(const TimeZoneTransition& that) const {
    87     return !operator==(that);
    88 }
    90 void
    91 TimeZoneTransition::setTime(UDate time) {
    92     fTime = time;
    93 }
    95 void
    96 TimeZoneTransition::setFrom(const TimeZoneRule& from) {
    97     if (fFrom != NULL) {
    98         delete fFrom;
    99     }
   100     fFrom = from.clone();
   101 }
   103 void
   104 TimeZoneTransition::adoptFrom(TimeZoneRule* from) {
   105     if (fFrom != NULL) {
   106         delete fFrom;
   107     }
   108     fFrom = from;
   109 }
   111 void
   112 TimeZoneTransition::setTo(const TimeZoneRule& to) {
   113     if (fTo != NULL) {
   114         delete fTo;
   115     }
   116     fTo = to.clone();
   117 }
   119 void
   120 TimeZoneTransition::adoptTo(TimeZoneRule* to) {
   121     if (fTo != NULL) {
   122         delete fTo;
   123     }
   124     fTo = to;
   125 }
   127 UDate
   128 TimeZoneTransition::getTime(void) const {
   129     return fTime;
   130 }
   132 const TimeZoneRule*
   133 TimeZoneTransition::getTo(void) const {
   134     return fTo;
   135 }
   137 const TimeZoneRule*
   138 TimeZoneTransition::getFrom(void) const {
   139     return fFrom;
   140 }
   142 U_NAMESPACE_END
   144 #endif
   146 //eof

mercurial