summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/i18n/vzone.cpp
blob: 6db3ba04c581f7e77adc8bee7cbc7575bc791acf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*/

/**
 * \file
 * \brief C API: VTimeZone classes
 */

#include "unicode/utypes.h"

#if !UCONFIG_NO_FORMATTING

#include "unicode/uobject.h"
#include "vzone.h"
#include "unicode/vtzone.h"
#include "cmemory.h"
#include "unicode/ustring.h"
#include "unicode/parsepos.h"

U_NAMESPACE_USE

U_CAPI VZone* U_EXPORT2
vzone_openID(const UChar* ID, int32_t idLength){
    UnicodeString s(idLength==-1, ID, idLength);
    return (VZone*) (VTimeZone::createVTimeZoneByID(s));
}

U_CAPI VZone* U_EXPORT2
vzone_openData(const UChar* vtzdata, int32_t vtzdataLength, UErrorCode& status) {
    UnicodeString s(vtzdataLength==-1, vtzdata, vtzdataLength);
    return (VZone*) (VTimeZone::createVTimeZone(s,status));
}

U_CAPI void U_EXPORT2
vzone_close(VZone* zone) {
    delete (VTimeZone*)zone;
}

U_CAPI VZone* U_EXPORT2
vzone_clone(const VZone *zone) {
    return (VZone*) (((VTimeZone*)zone)->VTimeZone::clone());
}

U_CAPI UBool U_EXPORT2
vzone_equals(const VZone* zone1, const VZone* zone2) {
    return *(const VTimeZone*)zone1 == *(const VTimeZone*)zone2;
}

U_CAPI UBool U_EXPORT2
vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength) {
    UnicodeString s;
    UBool b = ((VTimeZone*)zone)->VTimeZone::getTZURL(s);

    urlLength = s.length();
    memcpy(url,s.getBuffer(),urlLength);

    return b;
}

U_CAPI void U_EXPORT2
vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength) {
    UnicodeString s(urlLength==-1, url, urlLength);
    ((VTimeZone*)zone)->VTimeZone::setTZURL(s);
}

U_CAPI UBool U_EXPORT2
vzone_getLastModified(VZone* zone, UDate& lastModified) {
    return ((VTimeZone*)zone)->VTimeZone::getLastModified(lastModified);
}

U_CAPI void U_EXPORT2
vzone_setLastModified(VZone* zone, UDate lastModified) {
    return ((VTimeZone*)zone)->VTimeZone::setLastModified(lastModified);
}

U_CAPI void U_EXPORT2
vzone_write(VZone* zone, UChar* & result, int32_t & resultLength, UErrorCode& status) {
    UnicodeString s;
    ((VTimeZone*)zone)->VTimeZone::write(s, status);

    resultLength = s.length();
    result = (UChar*)uprv_malloc(resultLength);
    memcpy(result,s.getBuffer(),resultLength);

    return;
}

U_CAPI void U_EXPORT2
vzone_writeFromStart(VZone* zone, UDate start, UChar* & result, int32_t & resultLength, UErrorCode& status) {
    UnicodeString s;
    ((VTimeZone*)zone)->VTimeZone::write(start, s, status);

    resultLength = s.length();
    result = (UChar*)uprv_malloc(resultLength);
    memcpy(result,s.getBuffer(),resultLength);

    return;
}

U_CAPI void U_EXPORT2
vzone_writeSimple(VZone* zone, UDate time, UChar* & result, int32_t & resultLength, UErrorCode& status) {
    UnicodeString s;
    ((VTimeZone*)zone)->VTimeZone::writeSimple(time, s, status);

    resultLength = s.length();
    result = (UChar*)uprv_malloc(resultLength);
    memcpy(result,s.getBuffer(),resultLength);

    return;
}

U_CAPI int32_t U_EXPORT2
vzone_getOffset(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day,
                uint8_t dayOfWeek, int32_t millis, UErrorCode& status) {
    return ((VTimeZone*)zone)->VTimeZone::getOffset(era, year, month, day, dayOfWeek, millis, status);
}

U_CAPI int32_t U_EXPORT2
vzone_getOffset2(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day,
                uint8_t dayOfWeek, int32_t millis,
                int32_t monthLength, UErrorCode& status) {
    return ((VTimeZone*)zone)->VTimeZone::getOffset(era, year, month, day, dayOfWeek, millis, monthLength, status);
}

U_CAPI void U_EXPORT2
vzone_getOffset3(VZone* zone, UDate date, UBool local, int32_t& rawOffset,
                int32_t& dstOffset, UErrorCode& ec) {
    return ((VTimeZone*)zone)->VTimeZone::getOffset(date, local, rawOffset, dstOffset, ec);
}

U_CAPI void U_EXPORT2
vzone_setRawOffset(VZone* zone, int32_t offsetMillis) {
    return ((VTimeZone*)zone)->VTimeZone::setRawOffset(offsetMillis);
}

U_CAPI int32_t U_EXPORT2
vzone_getRawOffset(VZone* zone) {
    return ((VTimeZone*)zone)->VTimeZone::getRawOffset();
}

U_CAPI UBool U_EXPORT2
vzone_useDaylightTime(VZone* zone) {
    return ((VTimeZone*)zone)->VTimeZone::useDaylightTime();
}

U_CAPI UBool U_EXPORT2
vzone_inDaylightTime(VZone* zone, UDate date, UErrorCode& status) {
    return ((VTimeZone*)zone)->VTimeZone::inDaylightTime(date, status);
}

U_CAPI UBool U_EXPORT2
vzone_hasSameRules(VZone* zone, const VZone* other) {
    return ((VTimeZone*)zone)->VTimeZone::hasSameRules(*(VTimeZone*)other);
}

U_CAPI UBool U_EXPORT2
vzone_getNextTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result) {
    return ((VTimeZone*)zone)->VTimeZone::getNextTransition(base, inclusive, *(TimeZoneTransition*)result);
}

U_CAPI UBool U_EXPORT2
vzone_getPreviousTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result) {
    return ((VTimeZone*)zone)->VTimeZone::getPreviousTransition(base, inclusive, *(TimeZoneTransition*)result);
}

U_CAPI int32_t U_EXPORT2
vzone_countTransitionRules(VZone* zone, UErrorCode& status) {
    return ((VTimeZone*)zone)->VTimeZone::countTransitionRules(status);
}

U_CAPI UClassID U_EXPORT2
vzone_getStaticClassID(VZone* zone) {
    return ((VTimeZone*)zone)->VTimeZone::getStaticClassID();
}

U_CAPI UClassID U_EXPORT2
vzone_getDynamicClassID(VZone* zone) {
    return ((VTimeZone*)zone)->VTimeZone::getDynamicClassID();
}

#endif