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