1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/vzone.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,185 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* Copyright (C) 2009-2011, International Business Machines Corporation and 1.7 +* others. All Rights Reserved. 1.8 +******************************************************************************* 1.9 +*/ 1.10 + 1.11 +/** 1.12 + * \file 1.13 + * \brief C API: VTimeZone classes 1.14 + */ 1.15 + 1.16 +#include "unicode/utypes.h" 1.17 + 1.18 +#if !UCONFIG_NO_FORMATTING 1.19 + 1.20 +#include "unicode/uobject.h" 1.21 +#include "vzone.h" 1.22 +#include "unicode/vtzone.h" 1.23 +#include "cmemory.h" 1.24 +#include "unicode/ustring.h" 1.25 +#include "unicode/parsepos.h" 1.26 + 1.27 +U_NAMESPACE_USE 1.28 + 1.29 +U_CAPI VZone* U_EXPORT2 1.30 +vzone_openID(const UChar* ID, int32_t idLength){ 1.31 + UnicodeString s(idLength==-1, ID, idLength); 1.32 + return (VZone*) (VTimeZone::createVTimeZoneByID(s)); 1.33 +} 1.34 + 1.35 +U_CAPI VZone* U_EXPORT2 1.36 +vzone_openData(const UChar* vtzdata, int32_t vtzdataLength, UErrorCode& status) { 1.37 + UnicodeString s(vtzdataLength==-1, vtzdata, vtzdataLength); 1.38 + return (VZone*) (VTimeZone::createVTimeZone(s,status)); 1.39 +} 1.40 + 1.41 +U_CAPI void U_EXPORT2 1.42 +vzone_close(VZone* zone) { 1.43 + delete (VTimeZone*)zone; 1.44 +} 1.45 + 1.46 +U_CAPI VZone* U_EXPORT2 1.47 +vzone_clone(const VZone *zone) { 1.48 + return (VZone*) (((VTimeZone*)zone)->VTimeZone::clone()); 1.49 +} 1.50 + 1.51 +U_CAPI UBool U_EXPORT2 1.52 +vzone_equals(const VZone* zone1, const VZone* zone2) { 1.53 + return *(const VTimeZone*)zone1 == *(const VTimeZone*)zone2; 1.54 +} 1.55 + 1.56 +U_CAPI UBool U_EXPORT2 1.57 +vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength) { 1.58 + UnicodeString s; 1.59 + UBool b = ((VTimeZone*)zone)->VTimeZone::getTZURL(s); 1.60 + 1.61 + urlLength = s.length(); 1.62 + memcpy(url,s.getBuffer(),urlLength); 1.63 + 1.64 + return b; 1.65 +} 1.66 + 1.67 +U_CAPI void U_EXPORT2 1.68 +vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength) { 1.69 + UnicodeString s(urlLength==-1, url, urlLength); 1.70 + ((VTimeZone*)zone)->VTimeZone::setTZURL(s); 1.71 +} 1.72 + 1.73 +U_CAPI UBool U_EXPORT2 1.74 +vzone_getLastModified(VZone* zone, UDate& lastModified) { 1.75 + return ((VTimeZone*)zone)->VTimeZone::getLastModified(lastModified); 1.76 +} 1.77 + 1.78 +U_CAPI void U_EXPORT2 1.79 +vzone_setLastModified(VZone* zone, UDate lastModified) { 1.80 + return ((VTimeZone*)zone)->VTimeZone::setLastModified(lastModified); 1.81 +} 1.82 + 1.83 +U_CAPI void U_EXPORT2 1.84 +vzone_write(VZone* zone, UChar* & result, int32_t & resultLength, UErrorCode& status) { 1.85 + UnicodeString s; 1.86 + ((VTimeZone*)zone)->VTimeZone::write(s, status); 1.87 + 1.88 + resultLength = s.length(); 1.89 + result = (UChar*)uprv_malloc(resultLength); 1.90 + memcpy(result,s.getBuffer(),resultLength); 1.91 + 1.92 + return; 1.93 +} 1.94 + 1.95 +U_CAPI void U_EXPORT2 1.96 +vzone_writeFromStart(VZone* zone, UDate start, UChar* & result, int32_t & resultLength, UErrorCode& status) { 1.97 + UnicodeString s; 1.98 + ((VTimeZone*)zone)->VTimeZone::write(start, s, status); 1.99 + 1.100 + resultLength = s.length(); 1.101 + result = (UChar*)uprv_malloc(resultLength); 1.102 + memcpy(result,s.getBuffer(),resultLength); 1.103 + 1.104 + return; 1.105 +} 1.106 + 1.107 +U_CAPI void U_EXPORT2 1.108 +vzone_writeSimple(VZone* zone, UDate time, UChar* & result, int32_t & resultLength, UErrorCode& status) { 1.109 + UnicodeString s; 1.110 + ((VTimeZone*)zone)->VTimeZone::writeSimple(time, s, status); 1.111 + 1.112 + resultLength = s.length(); 1.113 + result = (UChar*)uprv_malloc(resultLength); 1.114 + memcpy(result,s.getBuffer(),resultLength); 1.115 + 1.116 + return; 1.117 +} 1.118 + 1.119 +U_CAPI int32_t U_EXPORT2 1.120 +vzone_getOffset(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day, 1.121 + uint8_t dayOfWeek, int32_t millis, UErrorCode& status) { 1.122 + return ((VTimeZone*)zone)->VTimeZone::getOffset(era, year, month, day, dayOfWeek, millis, status); 1.123 +} 1.124 + 1.125 +U_CAPI int32_t U_EXPORT2 1.126 +vzone_getOffset2(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day, 1.127 + uint8_t dayOfWeek, int32_t millis, 1.128 + int32_t monthLength, UErrorCode& status) { 1.129 + return ((VTimeZone*)zone)->VTimeZone::getOffset(era, year, month, day, dayOfWeek, millis, monthLength, status); 1.130 +} 1.131 + 1.132 +U_CAPI void U_EXPORT2 1.133 +vzone_getOffset3(VZone* zone, UDate date, UBool local, int32_t& rawOffset, 1.134 + int32_t& dstOffset, UErrorCode& ec) { 1.135 + return ((VTimeZone*)zone)->VTimeZone::getOffset(date, local, rawOffset, dstOffset, ec); 1.136 +} 1.137 + 1.138 +U_CAPI void U_EXPORT2 1.139 +vzone_setRawOffset(VZone* zone, int32_t offsetMillis) { 1.140 + return ((VTimeZone*)zone)->VTimeZone::setRawOffset(offsetMillis); 1.141 +} 1.142 + 1.143 +U_CAPI int32_t U_EXPORT2 1.144 +vzone_getRawOffset(VZone* zone) { 1.145 + return ((VTimeZone*)zone)->VTimeZone::getRawOffset(); 1.146 +} 1.147 + 1.148 +U_CAPI UBool U_EXPORT2 1.149 +vzone_useDaylightTime(VZone* zone) { 1.150 + return ((VTimeZone*)zone)->VTimeZone::useDaylightTime(); 1.151 +} 1.152 + 1.153 +U_CAPI UBool U_EXPORT2 1.154 +vzone_inDaylightTime(VZone* zone, UDate date, UErrorCode& status) { 1.155 + return ((VTimeZone*)zone)->VTimeZone::inDaylightTime(date, status); 1.156 +} 1.157 + 1.158 +U_CAPI UBool U_EXPORT2 1.159 +vzone_hasSameRules(VZone* zone, const VZone* other) { 1.160 + return ((VTimeZone*)zone)->VTimeZone::hasSameRules(*(VTimeZone*)other); 1.161 +} 1.162 + 1.163 +U_CAPI UBool U_EXPORT2 1.164 +vzone_getNextTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result) { 1.165 + return ((VTimeZone*)zone)->VTimeZone::getNextTransition(base, inclusive, *(TimeZoneTransition*)result); 1.166 +} 1.167 + 1.168 +U_CAPI UBool U_EXPORT2 1.169 +vzone_getPreviousTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result) { 1.170 + return ((VTimeZone*)zone)->VTimeZone::getPreviousTransition(base, inclusive, *(TimeZoneTransition*)result); 1.171 +} 1.172 + 1.173 +U_CAPI int32_t U_EXPORT2 1.174 +vzone_countTransitionRules(VZone* zone, UErrorCode& status) { 1.175 + return ((VTimeZone*)zone)->VTimeZone::countTransitionRules(status); 1.176 +} 1.177 + 1.178 +U_CAPI UClassID U_EXPORT2 1.179 +vzone_getStaticClassID(VZone* zone) { 1.180 + return ((VTimeZone*)zone)->VTimeZone::getStaticClassID(); 1.181 +} 1.182 + 1.183 +U_CAPI UClassID U_EXPORT2 1.184 +vzone_getDynamicClassID(VZone* zone) { 1.185 + return ((VTimeZone*)zone)->VTimeZone::getDynamicClassID(); 1.186 +} 1.187 + 1.188 +#endif