2 *******************************************************************************
3 * Copyright (C) 2009-2010, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
10 * \brief C API: VTimeZone classes
13 #include "unicode/utypes.h"
15 #if !UCONFIG_NO_FORMATTING
17 #include "unicode/uobject.h"
19 #include "unicode/vtzone.h"
21 #include "unicode/ustring.h"
22 #include "unicode/parsepos.h"
26 U_CAPI VZone
* U_EXPORT2
27 vzone_openID(const UChar
* ID
, int32_t idLength
){
28 UnicodeString
s(idLength
==-1, ID
, idLength
);
29 return (VZone
*) (VTimeZone::createVTimeZoneByID(s
));
32 U_CAPI VZone
* U_EXPORT2
33 vzone_openData(const UChar
* vtzdata
, int32_t vtzdataLength
, UErrorCode
& status
) {
34 UnicodeString
s(vtzdataLength
==-1, vtzdata
, vtzdataLength
);
35 return (VZone
*) (VTimeZone::createVTimeZone(s
,status
));
39 vzone_close(VZone
* zone
) {
40 delete (VTimeZone
*)zone
;
43 U_CAPI VZone
* U_EXPORT2
44 vzone_clone(const VZone
*zone
) {
45 return (VZone
*) (((VTimeZone
*)zone
)->VTimeZone::clone());
48 U_CAPI UBool U_EXPORT2
49 vzone_equals(const VZone
* zone1
, const VZone
* zone2
) {
50 return *(const VTimeZone
*)zone1
== *(const VTimeZone
*)zone2
;
53 U_CAPI UBool U_EXPORT2
54 vzone_getTZURL(VZone
* zone
, UChar
* & url
, int32_t & urlLength
) {
56 UBool b
= ((VTimeZone
*)zone
)->VTimeZone::getTZURL(s
);
58 urlLength
= s
.length();
59 memcpy(url
,s
.getBuffer(),urlLength
);
65 vzone_setTZURL(VZone
* zone
, UChar
* url
, int32_t urlLength
) {
66 UnicodeString
s(urlLength
==-1, url
, urlLength
);
67 return ((VTimeZone
*)zone
)->VTimeZone::setTZURL(url
);
70 U_CAPI UBool U_EXPORT2
71 vzone_getLastModified(VZone
* zone
, UDate
& lastModified
) {
72 return ((VTimeZone
*)zone
)->VTimeZone::getLastModified(lastModified
);
76 vzone_setLastModified(VZone
* zone
, UDate lastModified
) {
77 return ((VTimeZone
*)zone
)->VTimeZone::setLastModified(lastModified
);
81 vzone_write(VZone
* zone
, UChar
* & result
, int32_t & resultLength
, UErrorCode
& status
) {
83 ((VTimeZone
*)zone
)->VTimeZone::write(s
, status
);
85 resultLength
= s
.length();
86 result
= (UChar
*)uprv_malloc(resultLength
);
87 memcpy(result
,s
.getBuffer(),resultLength
);
93 vzone_writeFromStart(VZone
* zone
, UDate start
, UChar
* & result
, int32_t & resultLength
, UErrorCode
& status
) {
95 ((VTimeZone
*)zone
)->VTimeZone::write(start
, s
, status
);
97 resultLength
= s
.length();
98 result
= (UChar
*)uprv_malloc(resultLength
);
99 memcpy(result
,s
.getBuffer(),resultLength
);
104 U_CAPI
void U_EXPORT2
105 vzone_writeSimple(VZone
* zone
, UDate time
, UChar
* & result
, int32_t & resultLength
, UErrorCode
& status
) {
107 ((VTimeZone
*)zone
)->VTimeZone::writeSimple(time
, s
, status
);
109 resultLength
= s
.length();
110 result
= (UChar
*)uprv_malloc(resultLength
);
111 memcpy(result
,s
.getBuffer(),resultLength
);
116 U_CAPI
int32_t U_EXPORT2
117 vzone_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
);
122 U_CAPI
int32_t U_EXPORT2
123 vzone_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
);
129 U_CAPI
void U_EXPORT2
130 vzone_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
);
135 U_CAPI
void U_EXPORT2
136 vzone_setRawOffset(VZone
* zone
, int32_t offsetMillis
) {
137 return ((VTimeZone
*)zone
)->VTimeZone::setRawOffset(offsetMillis
);
140 U_CAPI
int32_t U_EXPORT2
141 vzone_getRawOffset(VZone
* zone
) {
142 return ((VTimeZone
*)zone
)->VTimeZone::getRawOffset();
145 U_CAPI UBool U_EXPORT2
146 vzone_useDaylightTime(VZone
* zone
) {
147 return ((VTimeZone
*)zone
)->VTimeZone::useDaylightTime();
150 U_CAPI UBool U_EXPORT2
151 vzone_inDaylightTime(VZone
* zone
, UDate date
, UErrorCode
& status
) {
152 return ((VTimeZone
*)zone
)->VTimeZone::inDaylightTime(date
, status
);
155 U_CAPI UBool U_EXPORT2
156 vzone_hasSameRules(VZone
* zone
, const VZone
* other
) {
157 return ((VTimeZone
*)zone
)->VTimeZone::hasSameRules(*(VTimeZone
*)other
);
160 U_CAPI UBool U_EXPORT2
161 vzone_getNextTransition(VZone
* zone
, UDate base
, UBool inclusive
, ZTrans
* result
) {
162 return ((VTimeZone
*)zone
)->VTimeZone::getNextTransition(base
, inclusive
, *(TimeZoneTransition
*)result
);
165 U_CAPI UBool U_EXPORT2
166 vzone_getPreviousTransition(VZone
* zone
, UDate base
, UBool inclusive
, ZTrans
* result
) {
167 return ((VTimeZone
*)zone
)->VTimeZone::getPreviousTransition(base
, inclusive
, *(TimeZoneTransition
*)result
);
170 U_CAPI
int32_t U_EXPORT2
171 vzone_countTransitionRules(VZone
* zone
, UErrorCode
& status
) {
172 return ((VTimeZone
*)zone
)->VTimeZone::countTransitionRules(status
);
175 U_CAPI UClassID U_EXPORT2
176 vzone_getStaticClassID(VZone
* zone
) {
177 return ((VTimeZone
*)zone
)->VTimeZone::getStaticClassID();
180 U_CAPI UClassID U_EXPORT2
181 vzone_getDynamicClassID(VZone
* zone
) {
182 return ((VTimeZone
*)zone
)->VTimeZone::getDynamicClassID();