Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * Copyright (C) 2009-2011, International Business Machines Corporation and |
michael@0 | 4 | * others. All Rights Reserved. |
michael@0 | 5 | ******************************************************************************* |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | /** |
michael@0 | 9 | * \file |
michael@0 | 10 | * \brief C API: Time zone rule classes |
michael@0 | 11 | */ |
michael@0 | 12 | |
michael@0 | 13 | #include "unicode/utypes.h" |
michael@0 | 14 | |
michael@0 | 15 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 16 | |
michael@0 | 17 | #include "unicode/uobject.h" |
michael@0 | 18 | #include "zrule.h" |
michael@0 | 19 | #include "unicode/tzrule.h" |
michael@0 | 20 | #include "cmemory.h" |
michael@0 | 21 | #include "unicode/ustring.h" |
michael@0 | 22 | #include "unicode/parsepos.h" |
michael@0 | 23 | |
michael@0 | 24 | U_NAMESPACE_USE |
michael@0 | 25 | |
michael@0 | 26 | /********************************************************************* |
michael@0 | 27 | * ZRule API |
michael@0 | 28 | *********************************************************************/ |
michael@0 | 29 | |
michael@0 | 30 | U_CAPI void U_EXPORT2 |
michael@0 | 31 | zrule_close(ZRule* rule) { |
michael@0 | 32 | delete (TimeZoneRule*)rule; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | U_CAPI UBool U_EXPORT2 |
michael@0 | 36 | zrule_equals(const ZRule* rule1, const ZRule* rule2) { |
michael@0 | 37 | return *(const TimeZoneRule*)rule1 == *(const TimeZoneRule*)rule2; |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | U_CAPI void U_EXPORT2 |
michael@0 | 41 | zrule_getName(ZRule* rule, UChar* name, int32_t nameLength) { |
michael@0 | 42 | UnicodeString s(nameLength==-1, name, nameLength); |
michael@0 | 43 | s = ((TimeZoneRule*)rule)->TimeZoneRule::getName(s); |
michael@0 | 44 | nameLength = s.length(); |
michael@0 | 45 | memcpy(name, s.getBuffer(), nameLength); |
michael@0 | 46 | return; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 50 | zrule_getRawOffset(ZRule* rule) { |
michael@0 | 51 | return ((TimeZoneRule*)rule)->TimeZoneRule::getRawOffset(); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 55 | zrule_getDSTSavings(ZRule* rule) { |
michael@0 | 56 | return ((TimeZoneRule*)rule)->TimeZoneRule::getDSTSavings(); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | U_CAPI UBool U_EXPORT2 |
michael@0 | 60 | zrule_isEquivalentTo(ZRule* rule1, ZRule* rule2) { |
michael@0 | 61 | return ((TimeZoneRule*)rule1)->TimeZoneRule::isEquivalentTo(*(TimeZoneRule*)rule2); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | /********************************************************************* |
michael@0 | 65 | * IZRule API |
michael@0 | 66 | *********************************************************************/ |
michael@0 | 67 | |
michael@0 | 68 | U_CAPI IZRule* U_EXPORT2 |
michael@0 | 69 | izrule_open(const UChar* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings) { |
michael@0 | 70 | UnicodeString s(nameLength==-1, name, nameLength); |
michael@0 | 71 | return (IZRule*) new InitialTimeZoneRule(s, rawOffset, dstSavings); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | U_CAPI void U_EXPORT2 |
michael@0 | 75 | izrule_close(IZRule* rule) { |
michael@0 | 76 | delete (InitialTimeZoneRule*)rule; |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | U_CAPI IZRule* U_EXPORT2 |
michael@0 | 80 | izrule_clone(IZRule *rule) { |
michael@0 | 81 | return (IZRule*) (((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::clone()); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | U_CAPI UBool U_EXPORT2 |
michael@0 | 85 | izrule_equals(const IZRule* rule1, const IZRule* rule2) { |
michael@0 | 86 | return *(const InitialTimeZoneRule*)rule1 == *(const InitialTimeZoneRule*)rule2; |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | U_CAPI void U_EXPORT2 |
michael@0 | 90 | izrule_getName(IZRule* rule, UChar* & name, int32_t & nameLength) { |
michael@0 | 91 | // UnicodeString s(nameLength==-1, name, nameLength); |
michael@0 | 92 | UnicodeString s; |
michael@0 | 93 | ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getName(s); |
michael@0 | 94 | nameLength = s.length(); |
michael@0 | 95 | name = (UChar*)uprv_malloc(nameLength); |
michael@0 | 96 | memcpy(name, s.getBuffer(), nameLength); |
michael@0 | 97 | return; |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 101 | izrule_getRawOffset(IZRule* rule) { |
michael@0 | 102 | return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getRawOffset(); |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 106 | izrule_getDSTSavings(IZRule* rule) { |
michael@0 | 107 | return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getDSTSavings(); |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | U_CAPI UBool U_EXPORT2 |
michael@0 | 111 | izrule_isEquivalentTo(IZRule* rule1, IZRule* rule2) { |
michael@0 | 112 | return ((InitialTimeZoneRule*)rule1)->InitialTimeZoneRule::isEquivalentTo(*(InitialTimeZoneRule*)rule2); |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | U_CAPI UBool U_EXPORT2 |
michael@0 | 116 | izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, |
michael@0 | 117 | UDate& result) { |
michael@0 | 118 | return ((const InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getFirstStart(prevRawOffset, prevDSTSavings, result); |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | U_CAPI UBool U_EXPORT2 |
michael@0 | 122 | izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, |
michael@0 | 123 | UDate& result) { |
michael@0 | 124 | return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getFinalStart(prevRawOffset, prevDSTSavings, result); |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | U_CAPI UBool U_EXPORT2 |
michael@0 | 128 | izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset, |
michael@0 | 129 | int32_t prevDSTSavings, UBool inclusive, UDate& result) { |
michael@0 | 130 | return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getNextStart(base, prevRawOffset, prevDSTSavings, inclusive, result); |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | U_CAPI UBool U_EXPORT2 |
michael@0 | 134 | izrule_getPreviousStart(IZRule* rule, UDate base, int32_t prevRawOffset, |
michael@0 | 135 | int32_t prevDSTSavings, UBool inclusive, UDate& result) { |
michael@0 | 136 | return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getPreviousStart(base, prevRawOffset, prevDSTSavings, inclusive, result); |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | U_CAPI UClassID U_EXPORT2 |
michael@0 | 140 | izrule_getStaticClassID(IZRule* rule) { |
michael@0 | 141 | return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getStaticClassID(); |
michael@0 | 142 | } |
michael@0 | 143 | |
michael@0 | 144 | U_CAPI UClassID U_EXPORT2 |
michael@0 | 145 | izrule_getDynamicClassID(IZRule* rule) { |
michael@0 | 146 | return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getDynamicClassID(); |
michael@0 | 147 | } |
michael@0 | 148 | |
michael@0 | 149 | #endif |