1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2009-2011, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 *******************************************************************************
12 * \brief C API: VTimeZone classes
15 #include "unicode/utypes.h"
17 #if !UCONFIG_NO_FORMATTING
19 #include "unicode/uobject.h"
21 #include "unicode/vtzone.h"
23 #include "unicode/ustring.h"
24 #include "unicode/parsepos.h"
28 U_CAPI VZone* U_EXPORT2
29 vzone_openID(const UChar* ID, int32_t idLength){
30 UnicodeString s(idLength==-1, ID, idLength);
31 return (VZone*) (VTimeZone::createVTimeZoneByID(s));
34 U_CAPI VZone* U_EXPORT2
35 vzone_openData(const UChar* vtzdata, int32_t vtzdataLength, UErrorCode& status) {
36 UnicodeString s(vtzdataLength==-1, vtzdata, vtzdataLength);
37 return (VZone*) (VTimeZone::createVTimeZone(s,status));
41 vzone_close(VZone* zone) {
42 delete (VTimeZone*)zone;
45 U_CAPI VZone* U_EXPORT2
46 vzone_clone(const VZone *zone) {
47 return (VZone*) (((VTimeZone*)zone)->VTimeZone::clone());
50 U_CAPI UBool U_EXPORT2
51 vzone_equals(const VZone* zone1, const VZone* zone2) {
52 return *(const VTimeZone*)zone1 == *(const VTimeZone*)zone2;
55 U_CAPI UBool U_EXPORT2
56 vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength) {
58 UBool b = ((VTimeZone*)zone)->VTimeZone::getTZURL(s);
60 urlLength = s.length();
61 memcpy(url,s.getBuffer(),urlLength);
67 vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength) {
68 UnicodeString s(urlLength==-1, url, urlLength);
69 ((VTimeZone*)zone)->VTimeZone::setTZURL(s);
72 U_CAPI UBool U_EXPORT2
73 vzone_getLastModified(VZone* zone, UDate& lastModified) {
74 return ((VTimeZone*)zone)->VTimeZone::getLastModified(lastModified);
78 vzone_setLastModified(VZone* zone, UDate lastModified) {
79 return ((VTimeZone*)zone)->VTimeZone::setLastModified(lastModified);
83 vzone_write(VZone* zone, UChar* & result, int32_t & resultLength, UErrorCode& status) {
85 ((VTimeZone*)zone)->VTimeZone::write(s, status);
87 resultLength = s.length();
88 result = (UChar*)uprv_malloc(resultLength);
89 memcpy(result,s.getBuffer(),resultLength);
95 vzone_writeFromStart(VZone* zone, UDate start, UChar* & result, int32_t & resultLength, UErrorCode& status) {
97 ((VTimeZone*)zone)->VTimeZone::write(start, s, status);
99 resultLength = s.length();
100 result = (UChar*)uprv_malloc(resultLength);
101 memcpy(result,s.getBuffer(),resultLength);
106 U_CAPI void U_EXPORT2
107 vzone_writeSimple(VZone* zone, UDate time, UChar* & result, int32_t & resultLength, UErrorCode& status) {
109 ((VTimeZone*)zone)->VTimeZone::writeSimple(time, s, status);
111 resultLength = s.length();
112 result = (UChar*)uprv_malloc(resultLength);
113 memcpy(result,s.getBuffer(),resultLength);
118 U_CAPI int32_t U_EXPORT2
119 vzone_getOffset(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day,
120 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) {
121 return ((VTimeZone*)zone)->VTimeZone::getOffset(era, year, month, day, dayOfWeek, millis, status);
124 U_CAPI int32_t U_EXPORT2
125 vzone_getOffset2(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day,
126 uint8_t dayOfWeek, int32_t millis,
127 int32_t monthLength, UErrorCode& status) {
128 return ((VTimeZone*)zone)->VTimeZone::getOffset(era, year, month, day, dayOfWeek, millis, monthLength, status);
131 U_CAPI void U_EXPORT2
132 vzone_getOffset3(VZone* zone, UDate date, UBool local, int32_t& rawOffset,
133 int32_t& dstOffset, UErrorCode& ec) {
134 return ((VTimeZone*)zone)->VTimeZone::getOffset(date, local, rawOffset, dstOffset, ec);
137 U_CAPI void U_EXPORT2
138 vzone_setRawOffset(VZone* zone, int32_t offsetMillis) {
139 return ((VTimeZone*)zone)->VTimeZone::setRawOffset(offsetMillis);
142 U_CAPI int32_t U_EXPORT2
143 vzone_getRawOffset(VZone* zone) {
144 return ((VTimeZone*)zone)->VTimeZone::getRawOffset();
147 U_CAPI UBool U_EXPORT2
148 vzone_useDaylightTime(VZone* zone) {
149 return ((VTimeZone*)zone)->VTimeZone::useDaylightTime();
152 U_CAPI UBool U_EXPORT2
153 vzone_inDaylightTime(VZone* zone, UDate date, UErrorCode& status) {
154 return ((VTimeZone*)zone)->VTimeZone::inDaylightTime(date, status);
157 U_CAPI UBool U_EXPORT2
158 vzone_hasSameRules(VZone* zone, const VZone* other) {
159 return ((VTimeZone*)zone)->VTimeZone::hasSameRules(*(VTimeZone*)other);
162 U_CAPI UBool U_EXPORT2
163 vzone_getNextTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result) {
164 return ((VTimeZone*)zone)->VTimeZone::getNextTransition(base, inclusive, *(TimeZoneTransition*)result);
167 U_CAPI UBool U_EXPORT2
168 vzone_getPreviousTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result) {
169 return ((VTimeZone*)zone)->VTimeZone::getPreviousTransition(base, inclusive, *(TimeZoneTransition*)result);
172 U_CAPI int32_t U_EXPORT2
173 vzone_countTransitionRules(VZone* zone, UErrorCode& status) {
174 return ((VTimeZone*)zone)->VTimeZone::countTransitionRules(status);
177 U_CAPI UClassID U_EXPORT2
178 vzone_getStaticClassID(VZone* zone) {
179 return ((VTimeZone*)zone)->VTimeZone::getStaticClassID();
182 U_CAPI UClassID U_EXPORT2
183 vzone_getDynamicClassID(VZone* zone) {
184 return ((VTimeZone*)zone)->VTimeZone::getDynamicClassID();