michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2009-2011, International Business Machines Corporation and michael@0: * others. All Rights Reserved. michael@0: ******************************************************************************* michael@0: */ michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C API: VTimeZone classes michael@0: */ michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/uobject.h" michael@0: #include "vzone.h" michael@0: #include "unicode/vtzone.h" michael@0: #include "cmemory.h" michael@0: #include "unicode/ustring.h" michael@0: #include "unicode/parsepos.h" michael@0: michael@0: U_NAMESPACE_USE michael@0: michael@0: U_CAPI VZone* U_EXPORT2 michael@0: vzone_openID(const UChar* ID, int32_t idLength){ michael@0: UnicodeString s(idLength==-1, ID, idLength); michael@0: return (VZone*) (VTimeZone::createVTimeZoneByID(s)); michael@0: } michael@0: michael@0: U_CAPI VZone* U_EXPORT2 michael@0: vzone_openData(const UChar* vtzdata, int32_t vtzdataLength, UErrorCode& status) { michael@0: UnicodeString s(vtzdataLength==-1, vtzdata, vtzdataLength); michael@0: return (VZone*) (VTimeZone::createVTimeZone(s,status)); michael@0: } michael@0: michael@0: U_CAPI void U_EXPORT2 michael@0: vzone_close(VZone* zone) { michael@0: delete (VTimeZone*)zone; michael@0: } michael@0: michael@0: U_CAPI VZone* U_EXPORT2 michael@0: vzone_clone(const VZone *zone) { michael@0: return (VZone*) (((VTimeZone*)zone)->VTimeZone::clone()); michael@0: } michael@0: michael@0: U_CAPI UBool U_EXPORT2 michael@0: vzone_equals(const VZone* zone1, const VZone* zone2) { michael@0: return *(const VTimeZone*)zone1 == *(const VTimeZone*)zone2; michael@0: } michael@0: michael@0: U_CAPI UBool U_EXPORT2 michael@0: vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength) { michael@0: UnicodeString s; michael@0: UBool b = ((VTimeZone*)zone)->VTimeZone::getTZURL(s); michael@0: michael@0: urlLength = s.length(); michael@0: memcpy(url,s.getBuffer(),urlLength); michael@0: michael@0: return b; michael@0: } michael@0: michael@0: U_CAPI void U_EXPORT2 michael@0: vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength) { michael@0: UnicodeString s(urlLength==-1, url, urlLength); michael@0: ((VTimeZone*)zone)->VTimeZone::setTZURL(s); michael@0: } michael@0: michael@0: U_CAPI UBool U_EXPORT2 michael@0: vzone_getLastModified(VZone* zone, UDate& lastModified) { michael@0: return ((VTimeZone*)zone)->VTimeZone::getLastModified(lastModified); michael@0: } michael@0: michael@0: U_CAPI void U_EXPORT2 michael@0: vzone_setLastModified(VZone* zone, UDate lastModified) { michael@0: return ((VTimeZone*)zone)->VTimeZone::setLastModified(lastModified); michael@0: } michael@0: michael@0: U_CAPI void U_EXPORT2 michael@0: vzone_write(VZone* zone, UChar* & result, int32_t & resultLength, UErrorCode& status) { michael@0: UnicodeString s; michael@0: ((VTimeZone*)zone)->VTimeZone::write(s, status); michael@0: michael@0: resultLength = s.length(); michael@0: result = (UChar*)uprv_malloc(resultLength); michael@0: memcpy(result,s.getBuffer(),resultLength); michael@0: michael@0: return; michael@0: } michael@0: michael@0: U_CAPI void U_EXPORT2 michael@0: vzone_writeFromStart(VZone* zone, UDate start, UChar* & result, int32_t & resultLength, UErrorCode& status) { michael@0: UnicodeString s; michael@0: ((VTimeZone*)zone)->VTimeZone::write(start, s, status); michael@0: michael@0: resultLength = s.length(); michael@0: result = (UChar*)uprv_malloc(resultLength); michael@0: memcpy(result,s.getBuffer(),resultLength); michael@0: michael@0: return; michael@0: } michael@0: michael@0: U_CAPI void U_EXPORT2 michael@0: vzone_writeSimple(VZone* zone, UDate time, UChar* & result, int32_t & resultLength, UErrorCode& status) { michael@0: UnicodeString s; michael@0: ((VTimeZone*)zone)->VTimeZone::writeSimple(time, s, status); michael@0: michael@0: resultLength = s.length(); michael@0: result = (UChar*)uprv_malloc(resultLength); michael@0: memcpy(result,s.getBuffer(),resultLength); michael@0: michael@0: return; michael@0: } michael@0: michael@0: U_CAPI int32_t U_EXPORT2 michael@0: vzone_getOffset(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day, michael@0: uint8_t dayOfWeek, int32_t millis, UErrorCode& status) { michael@0: return ((VTimeZone*)zone)->VTimeZone::getOffset(era, year, month, day, dayOfWeek, millis, status); michael@0: } michael@0: michael@0: U_CAPI int32_t U_EXPORT2 michael@0: vzone_getOffset2(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day, michael@0: uint8_t dayOfWeek, int32_t millis, michael@0: int32_t monthLength, UErrorCode& status) { michael@0: return ((VTimeZone*)zone)->VTimeZone::getOffset(era, year, month, day, dayOfWeek, millis, monthLength, status); michael@0: } michael@0: michael@0: U_CAPI void U_EXPORT2 michael@0: vzone_getOffset3(VZone* zone, UDate date, UBool local, int32_t& rawOffset, michael@0: int32_t& dstOffset, UErrorCode& ec) { michael@0: return ((VTimeZone*)zone)->VTimeZone::getOffset(date, local, rawOffset, dstOffset, ec); michael@0: } michael@0: michael@0: U_CAPI void U_EXPORT2 michael@0: vzone_setRawOffset(VZone* zone, int32_t offsetMillis) { michael@0: return ((VTimeZone*)zone)->VTimeZone::setRawOffset(offsetMillis); michael@0: } michael@0: michael@0: U_CAPI int32_t U_EXPORT2 michael@0: vzone_getRawOffset(VZone* zone) { michael@0: return ((VTimeZone*)zone)->VTimeZone::getRawOffset(); michael@0: } michael@0: michael@0: U_CAPI UBool U_EXPORT2 michael@0: vzone_useDaylightTime(VZone* zone) { michael@0: return ((VTimeZone*)zone)->VTimeZone::useDaylightTime(); michael@0: } michael@0: michael@0: U_CAPI UBool U_EXPORT2 michael@0: vzone_inDaylightTime(VZone* zone, UDate date, UErrorCode& status) { michael@0: return ((VTimeZone*)zone)->VTimeZone::inDaylightTime(date, status); michael@0: } michael@0: michael@0: U_CAPI UBool U_EXPORT2 michael@0: vzone_hasSameRules(VZone* zone, const VZone* other) { michael@0: return ((VTimeZone*)zone)->VTimeZone::hasSameRules(*(VTimeZone*)other); michael@0: } michael@0: michael@0: U_CAPI UBool U_EXPORT2 michael@0: vzone_getNextTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result) { michael@0: return ((VTimeZone*)zone)->VTimeZone::getNextTransition(base, inclusive, *(TimeZoneTransition*)result); michael@0: } michael@0: michael@0: U_CAPI UBool U_EXPORT2 michael@0: vzone_getPreviousTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result) { michael@0: return ((VTimeZone*)zone)->VTimeZone::getPreviousTransition(base, inclusive, *(TimeZoneTransition*)result); michael@0: } michael@0: michael@0: U_CAPI int32_t U_EXPORT2 michael@0: vzone_countTransitionRules(VZone* zone, UErrorCode& status) { michael@0: return ((VTimeZone*)zone)->VTimeZone::countTransitionRules(status); michael@0: } michael@0: michael@0: U_CAPI UClassID U_EXPORT2 michael@0: vzone_getStaticClassID(VZone* zone) { michael@0: return ((VTimeZone*)zone)->VTimeZone::getStaticClassID(); michael@0: } michael@0: michael@0: U_CAPI UClassID U_EXPORT2 michael@0: vzone_getDynamicClassID(VZone* zone) { michael@0: return ((VTimeZone*)zone)->VTimeZone::getDynamicClassID(); michael@0: } michael@0: michael@0: #endif