| |
1 /* |
| |
2 ******************************************************************************* |
| |
3 * Copyright (C) 2009-2011, 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 |
| |
24 U_NAMESPACE_USE |
| |
25 |
| |
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)); |
| |
30 } |
| |
31 |
| |
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)); |
| |
36 } |
| |
37 |
| |
38 U_CAPI void U_EXPORT2 |
| |
39 vzone_close(VZone* zone) { |
| |
40 delete (VTimeZone*)zone; |
| |
41 } |
| |
42 |
| |
43 U_CAPI VZone* U_EXPORT2 |
| |
44 vzone_clone(const VZone *zone) { |
| |
45 return (VZone*) (((VTimeZone*)zone)->VTimeZone::clone()); |
| |
46 } |
| |
47 |
| |
48 U_CAPI UBool U_EXPORT2 |
| |
49 vzone_equals(const VZone* zone1, const VZone* zone2) { |
| |
50 return *(const VTimeZone*)zone1 == *(const VTimeZone*)zone2; |
| |
51 } |
| |
52 |
| |
53 U_CAPI UBool U_EXPORT2 |
| |
54 vzone_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 |
| |
64 U_CAPI void U_EXPORT2 |
| |
65 vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength) { |
| |
66 UnicodeString s(urlLength==-1, url, urlLength); |
| |
67 ((VTimeZone*)zone)->VTimeZone::setTZURL(s); |
| |
68 } |
| |
69 |
| |
70 U_CAPI UBool U_EXPORT2 |
| |
71 vzone_getLastModified(VZone* zone, UDate& lastModified) { |
| |
72 return ((VTimeZone*)zone)->VTimeZone::getLastModified(lastModified); |
| |
73 } |
| |
74 |
| |
75 U_CAPI void U_EXPORT2 |
| |
76 vzone_setLastModified(VZone* zone, UDate lastModified) { |
| |
77 return ((VTimeZone*)zone)->VTimeZone::setLastModified(lastModified); |
| |
78 } |
| |
79 |
| |
80 U_CAPI void U_EXPORT2 |
| |
81 vzone_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 |
| |
92 U_CAPI void U_EXPORT2 |
| |
93 vzone_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 |
| |
104 U_CAPI void U_EXPORT2 |
| |
105 vzone_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 |
| |
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); |
| |
120 } |
| |
121 |
| |
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); |
| |
127 } |
| |
128 |
| |
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); |
| |
133 } |
| |
134 |
| |
135 U_CAPI void U_EXPORT2 |
| |
136 vzone_setRawOffset(VZone* zone, int32_t offsetMillis) { |
| |
137 return ((VTimeZone*)zone)->VTimeZone::setRawOffset(offsetMillis); |
| |
138 } |
| |
139 |
| |
140 U_CAPI int32_t U_EXPORT2 |
| |
141 vzone_getRawOffset(VZone* zone) { |
| |
142 return ((VTimeZone*)zone)->VTimeZone::getRawOffset(); |
| |
143 } |
| |
144 |
| |
145 U_CAPI UBool U_EXPORT2 |
| |
146 vzone_useDaylightTime(VZone* zone) { |
| |
147 return ((VTimeZone*)zone)->VTimeZone::useDaylightTime(); |
| |
148 } |
| |
149 |
| |
150 U_CAPI UBool U_EXPORT2 |
| |
151 vzone_inDaylightTime(VZone* zone, UDate date, UErrorCode& status) { |
| |
152 return ((VTimeZone*)zone)->VTimeZone::inDaylightTime(date, status); |
| |
153 } |
| |
154 |
| |
155 U_CAPI UBool U_EXPORT2 |
| |
156 vzone_hasSameRules(VZone* zone, const VZone* other) { |
| |
157 return ((VTimeZone*)zone)->VTimeZone::hasSameRules(*(VTimeZone*)other); |
| |
158 } |
| |
159 |
| |
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); |
| |
163 } |
| |
164 |
| |
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); |
| |
168 } |
| |
169 |
| |
170 U_CAPI int32_t U_EXPORT2 |
| |
171 vzone_countTransitionRules(VZone* zone, UErrorCode& status) { |
| |
172 return ((VTimeZone*)zone)->VTimeZone::countTransitionRules(status); |
| |
173 } |
| |
174 |
| |
175 U_CAPI UClassID U_EXPORT2 |
| |
176 vzone_getStaticClassID(VZone* zone) { |
| |
177 return ((VTimeZone*)zone)->VTimeZone::getStaticClassID(); |
| |
178 } |
| |
179 |
| |
180 U_CAPI UClassID U_EXPORT2 |
| |
181 vzone_getDynamicClassID(VZone* zone) { |
| |
182 return ((VTimeZone*)zone)->VTimeZone::getDynamicClassID(); |
| |
183 } |
| |
184 |
| |
185 #endif |