intl/icu/source/i18n/vzone.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*
     2 *******************************************************************************
     3 * Copyright (C) 2009-2011, International Business Machines Corporation and
     4 * others. All Rights Reserved.
     5 *******************************************************************************
     6 */
     8 /**
     9  * \file 
    10  * \brief C API: VTimeZone classes
    11  */
    13 #include "unicode/utypes.h"
    15 #if !UCONFIG_NO_FORMATTING
    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"
    24 U_NAMESPACE_USE
    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 }
    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 }
    38 U_CAPI void U_EXPORT2
    39 vzone_close(VZone* zone) {
    40     delete (VTimeZone*)zone;
    41 }
    43 U_CAPI VZone* U_EXPORT2
    44 vzone_clone(const VZone *zone) {
    45     return (VZone*) (((VTimeZone*)zone)->VTimeZone::clone());
    46 }
    48 U_CAPI UBool U_EXPORT2
    49 vzone_equals(const VZone* zone1, const VZone* zone2) {
    50     return *(const VTimeZone*)zone1 == *(const VTimeZone*)zone2;
    51 }
    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);
    58     urlLength = s.length();
    59     memcpy(url,s.getBuffer(),urlLength);
    61     return b;
    62 }
    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 }
    70 U_CAPI UBool U_EXPORT2
    71 vzone_getLastModified(VZone* zone, UDate& lastModified) {
    72     return ((VTimeZone*)zone)->VTimeZone::getLastModified(lastModified);
    73 }
    75 U_CAPI void U_EXPORT2
    76 vzone_setLastModified(VZone* zone, UDate lastModified) {
    77     return ((VTimeZone*)zone)->VTimeZone::setLastModified(lastModified);
    78 }
    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);
    85     resultLength = s.length();
    86     result = (UChar*)uprv_malloc(resultLength);
    87     memcpy(result,s.getBuffer(),resultLength);
    89     return;
    90 }
    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);
    97     resultLength = s.length();
    98     result = (UChar*)uprv_malloc(resultLength);
    99     memcpy(result,s.getBuffer(),resultLength);
   101     return;
   102 }
   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);
   109     resultLength = s.length();
   110     result = (UChar*)uprv_malloc(resultLength);
   111     memcpy(result,s.getBuffer(),resultLength);
   113     return;
   114 }
   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 }
   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 }
   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 }
   135 U_CAPI void U_EXPORT2
   136 vzone_setRawOffset(VZone* zone, int32_t offsetMillis) {
   137     return ((VTimeZone*)zone)->VTimeZone::setRawOffset(offsetMillis);
   138 }
   140 U_CAPI int32_t U_EXPORT2
   141 vzone_getRawOffset(VZone* zone) {
   142     return ((VTimeZone*)zone)->VTimeZone::getRawOffset();
   143 }
   145 U_CAPI UBool U_EXPORT2
   146 vzone_useDaylightTime(VZone* zone) {
   147     return ((VTimeZone*)zone)->VTimeZone::useDaylightTime();
   148 }
   150 U_CAPI UBool U_EXPORT2
   151 vzone_inDaylightTime(VZone* zone, UDate date, UErrorCode& status) {
   152     return ((VTimeZone*)zone)->VTimeZone::inDaylightTime(date, status);
   153 }
   155 U_CAPI UBool U_EXPORT2
   156 vzone_hasSameRules(VZone* zone, const VZone* other) {
   157     return ((VTimeZone*)zone)->VTimeZone::hasSameRules(*(VTimeZone*)other);
   158 }
   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 }
   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 }
   170 U_CAPI int32_t U_EXPORT2
   171 vzone_countTransitionRules(VZone* zone, UErrorCode& status) {
   172     return ((VTimeZone*)zone)->VTimeZone::countTransitionRules(status);
   173 }
   175 U_CAPI UClassID U_EXPORT2
   176 vzone_getStaticClassID(VZone* zone) {
   177     return ((VTimeZone*)zone)->VTimeZone::getStaticClassID();
   178 }
   180 U_CAPI UClassID U_EXPORT2
   181 vzone_getDynamicClassID(VZone* zone) {
   182     return ((VTimeZone*)zone)->VTimeZone::getDynamicClassID();
   183 }
   185 #endif

mercurial