intl/icu/source/i18n/vzone.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.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 * Copyright (C) 2009-2011, International Business Machines Corporation and
michael@0 4 * others. All Rights Reserved.
michael@0 5 *******************************************************************************
michael@0 6 */
michael@0 7
michael@0 8 /**
michael@0 9 * \file
michael@0 10 * \brief C API: VTimeZone classes
michael@0 11 */
michael@0 12
michael@0 13 #include "unicode/utypes.h"
michael@0 14
michael@0 15 #if !UCONFIG_NO_FORMATTING
michael@0 16
michael@0 17 #include "unicode/uobject.h"
michael@0 18 #include "vzone.h"
michael@0 19 #include "unicode/vtzone.h"
michael@0 20 #include "cmemory.h"
michael@0 21 #include "unicode/ustring.h"
michael@0 22 #include "unicode/parsepos.h"
michael@0 23
michael@0 24 U_NAMESPACE_USE
michael@0 25
michael@0 26 U_CAPI VZone* U_EXPORT2
michael@0 27 vzone_openID(const UChar* ID, int32_t idLength){
michael@0 28 UnicodeString s(idLength==-1, ID, idLength);
michael@0 29 return (VZone*) (VTimeZone::createVTimeZoneByID(s));
michael@0 30 }
michael@0 31
michael@0 32 U_CAPI VZone* U_EXPORT2
michael@0 33 vzone_openData(const UChar* vtzdata, int32_t vtzdataLength, UErrorCode& status) {
michael@0 34 UnicodeString s(vtzdataLength==-1, vtzdata, vtzdataLength);
michael@0 35 return (VZone*) (VTimeZone::createVTimeZone(s,status));
michael@0 36 }
michael@0 37
michael@0 38 U_CAPI void U_EXPORT2
michael@0 39 vzone_close(VZone* zone) {
michael@0 40 delete (VTimeZone*)zone;
michael@0 41 }
michael@0 42
michael@0 43 U_CAPI VZone* U_EXPORT2
michael@0 44 vzone_clone(const VZone *zone) {
michael@0 45 return (VZone*) (((VTimeZone*)zone)->VTimeZone::clone());
michael@0 46 }
michael@0 47
michael@0 48 U_CAPI UBool U_EXPORT2
michael@0 49 vzone_equals(const VZone* zone1, const VZone* zone2) {
michael@0 50 return *(const VTimeZone*)zone1 == *(const VTimeZone*)zone2;
michael@0 51 }
michael@0 52
michael@0 53 U_CAPI UBool U_EXPORT2
michael@0 54 vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength) {
michael@0 55 UnicodeString s;
michael@0 56 UBool b = ((VTimeZone*)zone)->VTimeZone::getTZURL(s);
michael@0 57
michael@0 58 urlLength = s.length();
michael@0 59 memcpy(url,s.getBuffer(),urlLength);
michael@0 60
michael@0 61 return b;
michael@0 62 }
michael@0 63
michael@0 64 U_CAPI void U_EXPORT2
michael@0 65 vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength) {
michael@0 66 UnicodeString s(urlLength==-1, url, urlLength);
michael@0 67 ((VTimeZone*)zone)->VTimeZone::setTZURL(s);
michael@0 68 }
michael@0 69
michael@0 70 U_CAPI UBool U_EXPORT2
michael@0 71 vzone_getLastModified(VZone* zone, UDate& lastModified) {
michael@0 72 return ((VTimeZone*)zone)->VTimeZone::getLastModified(lastModified);
michael@0 73 }
michael@0 74
michael@0 75 U_CAPI void U_EXPORT2
michael@0 76 vzone_setLastModified(VZone* zone, UDate lastModified) {
michael@0 77 return ((VTimeZone*)zone)->VTimeZone::setLastModified(lastModified);
michael@0 78 }
michael@0 79
michael@0 80 U_CAPI void U_EXPORT2
michael@0 81 vzone_write(VZone* zone, UChar* & result, int32_t & resultLength, UErrorCode& status) {
michael@0 82 UnicodeString s;
michael@0 83 ((VTimeZone*)zone)->VTimeZone::write(s, status);
michael@0 84
michael@0 85 resultLength = s.length();
michael@0 86 result = (UChar*)uprv_malloc(resultLength);
michael@0 87 memcpy(result,s.getBuffer(),resultLength);
michael@0 88
michael@0 89 return;
michael@0 90 }
michael@0 91
michael@0 92 U_CAPI void U_EXPORT2
michael@0 93 vzone_writeFromStart(VZone* zone, UDate start, UChar* & result, int32_t & resultLength, UErrorCode& status) {
michael@0 94 UnicodeString s;
michael@0 95 ((VTimeZone*)zone)->VTimeZone::write(start, s, status);
michael@0 96
michael@0 97 resultLength = s.length();
michael@0 98 result = (UChar*)uprv_malloc(resultLength);
michael@0 99 memcpy(result,s.getBuffer(),resultLength);
michael@0 100
michael@0 101 return;
michael@0 102 }
michael@0 103
michael@0 104 U_CAPI void U_EXPORT2
michael@0 105 vzone_writeSimple(VZone* zone, UDate time, UChar* & result, int32_t & resultLength, UErrorCode& status) {
michael@0 106 UnicodeString s;
michael@0 107 ((VTimeZone*)zone)->VTimeZone::writeSimple(time, s, status);
michael@0 108
michael@0 109 resultLength = s.length();
michael@0 110 result = (UChar*)uprv_malloc(resultLength);
michael@0 111 memcpy(result,s.getBuffer(),resultLength);
michael@0 112
michael@0 113 return;
michael@0 114 }
michael@0 115
michael@0 116 U_CAPI int32_t U_EXPORT2
michael@0 117 vzone_getOffset(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day,
michael@0 118 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) {
michael@0 119 return ((VTimeZone*)zone)->VTimeZone::getOffset(era, year, month, day, dayOfWeek, millis, status);
michael@0 120 }
michael@0 121
michael@0 122 U_CAPI int32_t U_EXPORT2
michael@0 123 vzone_getOffset2(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day,
michael@0 124 uint8_t dayOfWeek, int32_t millis,
michael@0 125 int32_t monthLength, UErrorCode& status) {
michael@0 126 return ((VTimeZone*)zone)->VTimeZone::getOffset(era, year, month, day, dayOfWeek, millis, monthLength, status);
michael@0 127 }
michael@0 128
michael@0 129 U_CAPI void U_EXPORT2
michael@0 130 vzone_getOffset3(VZone* zone, UDate date, UBool local, int32_t& rawOffset,
michael@0 131 int32_t& dstOffset, UErrorCode& ec) {
michael@0 132 return ((VTimeZone*)zone)->VTimeZone::getOffset(date, local, rawOffset, dstOffset, ec);
michael@0 133 }
michael@0 134
michael@0 135 U_CAPI void U_EXPORT2
michael@0 136 vzone_setRawOffset(VZone* zone, int32_t offsetMillis) {
michael@0 137 return ((VTimeZone*)zone)->VTimeZone::setRawOffset(offsetMillis);
michael@0 138 }
michael@0 139
michael@0 140 U_CAPI int32_t U_EXPORT2
michael@0 141 vzone_getRawOffset(VZone* zone) {
michael@0 142 return ((VTimeZone*)zone)->VTimeZone::getRawOffset();
michael@0 143 }
michael@0 144
michael@0 145 U_CAPI UBool U_EXPORT2
michael@0 146 vzone_useDaylightTime(VZone* zone) {
michael@0 147 return ((VTimeZone*)zone)->VTimeZone::useDaylightTime();
michael@0 148 }
michael@0 149
michael@0 150 U_CAPI UBool U_EXPORT2
michael@0 151 vzone_inDaylightTime(VZone* zone, UDate date, UErrorCode& status) {
michael@0 152 return ((VTimeZone*)zone)->VTimeZone::inDaylightTime(date, status);
michael@0 153 }
michael@0 154
michael@0 155 U_CAPI UBool U_EXPORT2
michael@0 156 vzone_hasSameRules(VZone* zone, const VZone* other) {
michael@0 157 return ((VTimeZone*)zone)->VTimeZone::hasSameRules(*(VTimeZone*)other);
michael@0 158 }
michael@0 159
michael@0 160 U_CAPI UBool U_EXPORT2
michael@0 161 vzone_getNextTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result) {
michael@0 162 return ((VTimeZone*)zone)->VTimeZone::getNextTransition(base, inclusive, *(TimeZoneTransition*)result);
michael@0 163 }
michael@0 164
michael@0 165 U_CAPI UBool U_EXPORT2
michael@0 166 vzone_getPreviousTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result) {
michael@0 167 return ((VTimeZone*)zone)->VTimeZone::getPreviousTransition(base, inclusive, *(TimeZoneTransition*)result);
michael@0 168 }
michael@0 169
michael@0 170 U_CAPI int32_t U_EXPORT2
michael@0 171 vzone_countTransitionRules(VZone* zone, UErrorCode& status) {
michael@0 172 return ((VTimeZone*)zone)->VTimeZone::countTransitionRules(status);
michael@0 173 }
michael@0 174
michael@0 175 U_CAPI UClassID U_EXPORT2
michael@0 176 vzone_getStaticClassID(VZone* zone) {
michael@0 177 return ((VTimeZone*)zone)->VTimeZone::getStaticClassID();
michael@0 178 }
michael@0 179
michael@0 180 U_CAPI UClassID U_EXPORT2
michael@0 181 vzone_getDynamicClassID(VZone* zone) {
michael@0 182 return ((VTimeZone*)zone)->VTimeZone::getDynamicClassID();
michael@0 183 }
michael@0 184
michael@0 185 #endif

mercurial