intl/icu/source/i18n/unicode/tzrule.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/unicode/tzrule.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,828 @@
     1.4 +/*
     1.5 +*******************************************************************************
     1.6 +* Copyright (C) 2007-2008, International Business Machines Corporation and    *
     1.7 +* others. All Rights Reserved.                                                *
     1.8 +*******************************************************************************
     1.9 +*/
    1.10 +#ifndef TZRULE_H
    1.11 +#define TZRULE_H
    1.12 +
    1.13 +/**
    1.14 + * \file 
    1.15 + * \brief C++ API: Time zone rule classes
    1.16 + */
    1.17 +
    1.18 +#include "unicode/utypes.h"
    1.19 +
    1.20 +#if !UCONFIG_NO_FORMATTING
    1.21 +
    1.22 +#include "unicode/uobject.h"
    1.23 +#include "unicode/unistr.h"
    1.24 +#include "unicode/dtrule.h"
    1.25 +
    1.26 +U_NAMESPACE_BEGIN
    1.27 +
    1.28 +/**
    1.29 + * <code>TimeZoneRule</code> is a class representing a rule for time zone.
    1.30 + * <code>TimeZoneRule</code> has a set of time zone attributes, such as zone name,
    1.31 + * raw offset (UTC offset for standard time) and daylight saving time offset.
    1.32 + * 
    1.33 + * @stable ICU 3.8
    1.34 + */
    1.35 +class U_I18N_API TimeZoneRule : public UObject {
    1.36 +public:
    1.37 +    /**
    1.38 +     * Destructor.
    1.39 +     * @stable ICU 3.8
    1.40 +     */
    1.41 +    virtual ~TimeZoneRule();
    1.42 +
    1.43 +    /**
    1.44 +     * Clone this TimeZoneRule object polymorphically. The caller owns the result and
    1.45 +     * should delete it when done.
    1.46 +     * @return  A copy of the object.
    1.47 +     * @stable ICU 3.8
    1.48 +     */
    1.49 +    virtual TimeZoneRule* clone(void) const = 0;
    1.50 +
    1.51 +    /**
    1.52 +     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
    1.53 +     * of different subclasses are considered unequal.
    1.54 +     * @param that  The object to be compared with.
    1.55 +     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.
    1.56 +     * @stable ICU 3.8
    1.57 +     */
    1.58 +    virtual UBool operator==(const TimeZoneRule& that) const;
    1.59 +
    1.60 +    /**
    1.61 +     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
    1.62 +     * of different subclasses are considered unequal.
    1.63 +     * @param that  The object to be compared with.
    1.64 +     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.
    1.65 +     * @stable ICU 3.8
    1.66 +     */
    1.67 +    virtual UBool operator!=(const TimeZoneRule& that) const;
    1.68 +
    1.69 +    /**
    1.70 +     * Fills in "name" with the name of this time zone.
    1.71 +     * @param name  Receives the name of this time zone.
    1.72 +     * @return  A reference to "name"
    1.73 +     * @stable ICU 3.8
    1.74 +     */
    1.75 +    UnicodeString& getName(UnicodeString& name) const;
    1.76 +
    1.77 +    /**
    1.78 +     * Gets the standard time offset.
    1.79 +     * @return  The standard time offset from UTC in milliseconds.
    1.80 +     * @stable ICU 3.8
    1.81 +     */
    1.82 +    int32_t getRawOffset(void) const;
    1.83 +
    1.84 +    /**
    1.85 +     * Gets the amount of daylight saving delta time from the standard time.
    1.86 +     * @return  The amount of daylight saving offset used by this rule
    1.87 +     *          in milliseconds.
    1.88 +     * @stable ICU 3.8
    1.89 +     */
    1.90 +    int32_t getDSTSavings(void) const;
    1.91 +
    1.92 +    /**
    1.93 +     * Returns if this rule represents the same rule and offsets as another.
    1.94 +     * When two <code>TimeZoneRule</code> objects differ only its names, this method
    1.95 +     * returns true.
    1.96 +     * @param other The <code>TimeZoneRule</code> object to be compared with.
    1.97 +     * @return  true if the other <code>TimeZoneRule</code> is the same as this one.
    1.98 +     * @stable ICU 3.8
    1.99 +     */
   1.100 +    virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
   1.101 +
   1.102 +    /**
   1.103 +     * Gets the very first time when this rule takes effect.
   1.104 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.105 +     *                          takes effect in milliseconds.
   1.106 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.107 +     *                          standard time.
   1.108 +     * @param result            Receives the very first time when this rule takes effect.
   1.109 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.110 +     *          "result" is unchanged.
   1.111 +     * @stable ICU 3.8
   1.112 +     */
   1.113 +    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
   1.114 +
   1.115 +    /**
   1.116 +     * Gets the final time when this rule takes effect.
   1.117 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.118 +     *                          takes effect in milliseconds.
   1.119 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.120 +     *                          standard time.
   1.121 +     * @param result            Receives the final time when this rule takes effect.
   1.122 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.123 +     *          "result" is unchanged.
   1.124 +     * @stable ICU 3.8
   1.125 +     */
   1.126 +    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
   1.127 +
   1.128 +    /**
   1.129 +     * Gets the first time when this rule takes effect after the specified time.
   1.130 +     * @param base              The first start time after this base time will be returned.
   1.131 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.132 +     *                          takes effect in milliseconds.
   1.133 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.134 +     *                          standard time.
   1.135 +     * @param inclusive         Whether the base time is inclusive or not.
   1.136 +     * @param result            Receives The first time when this rule takes effect after
   1.137 +     *                          the specified base time.
   1.138 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.139 +     *          "result" is unchanged.
   1.140 +     * @stable ICU 3.8
   1.141 +     */
   1.142 +    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
   1.143 +        UBool inclusive, UDate& result) const = 0;
   1.144 +
   1.145 +    /**
   1.146 +     * Gets the most recent time when this rule takes effect before the specified time.
   1.147 +     * @param base              The most recent time before this base time will be returned.
   1.148 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.149 +     *                          takes effect in milliseconds.
   1.150 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.151 +     *                          standard time.
   1.152 +     * @param inclusive         Whether the base time is inclusive or not.
   1.153 +     * @param result            Receives The most recent time when this rule takes effect before
   1.154 +     *                          the specified base time.
   1.155 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.156 +     *          "result" is unchanged.
   1.157 +     * @stable ICU 3.8
   1.158 +     */
   1.159 +    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
   1.160 +        UBool inclusive, UDate& result) const = 0;
   1.161 +
   1.162 +protected:
   1.163 +
   1.164 +    /**
   1.165 +     * Constructs a <code>TimeZoneRule</code> with the name, the GMT offset of its
   1.166 +     * standard time and the amount of daylight saving offset adjustment.
   1.167 +     * @param name          The time zone name.
   1.168 +     * @param rawOffset     The UTC offset of its standard time in milliseconds.
   1.169 +     * @param dstSavings    The amount of daylight saving offset adjustment in milliseconds.
   1.170 +     *                      If this ia a rule for standard time, the value of this argument is 0.
   1.171 +     * @stable ICU 3.8
   1.172 +     */
   1.173 +    TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
   1.174 +
   1.175 +    /**
   1.176 +     * Copy constructor.
   1.177 +     * @param source    The TimeZoneRule object to be copied.
   1.178 +     * @stable ICU 3.8
   1.179 +     */
   1.180 +    TimeZoneRule(const TimeZoneRule& source);
   1.181 +
   1.182 +    /**
   1.183 +     * Assignment operator.
   1.184 +     * @param right The object to be copied.
   1.185 +     * @stable ICU 3.8
   1.186 +     */
   1.187 +    TimeZoneRule& operator=(const TimeZoneRule& right);
   1.188 +
   1.189 +private:
   1.190 +    UnicodeString fName; // time name
   1.191 +    int32_t fRawOffset;  // UTC offset of the standard time in milliseconds
   1.192 +    int32_t fDSTSavings; // DST saving amount in milliseconds
   1.193 +};
   1.194 +
   1.195 +/**
   1.196 + * <code>InitialTimeZoneRule</code> represents a time zone rule
   1.197 + * representing a time zone effective from the beginning and
   1.198 + * has no actual start times.
   1.199 + * @stable ICU 3.8
   1.200 + */
   1.201 +class U_I18N_API InitialTimeZoneRule : public TimeZoneRule {
   1.202 +public:
   1.203 +    /**
   1.204 +     * Constructs an <code>InitialTimeZoneRule</code> with the name, the GMT offset of its
   1.205 +     * standard time and the amount of daylight saving offset adjustment.
   1.206 +     * @param name          The time zone name.
   1.207 +     * @param rawOffset     The UTC offset of its standard time in milliseconds.
   1.208 +     * @param dstSavings    The amount of daylight saving offset adjustment in milliseconds.
   1.209 +     *                      If this ia a rule for standard time, the value of this argument is 0.
   1.210 +     * @stable ICU 3.8
   1.211 +     */
   1.212 +    InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
   1.213 +
   1.214 +    /**
   1.215 +     * Copy constructor.
   1.216 +     * @param source    The InitialTimeZoneRule object to be copied.
   1.217 +     * @stable ICU 3.8
   1.218 +     */
   1.219 +    InitialTimeZoneRule(const InitialTimeZoneRule& source);
   1.220 +
   1.221 +    /**
   1.222 +     * Destructor.
   1.223 +     * @stable ICU 3.8
   1.224 +     */
   1.225 +    virtual ~InitialTimeZoneRule();
   1.226 +
   1.227 +    /**
   1.228 +     * Clone this InitialTimeZoneRule object polymorphically. The caller owns the result and
   1.229 +     * should delete it when done.
   1.230 +     * @return    A copy of the object.
   1.231 +     * @stable ICU 3.8
   1.232 +     */
   1.233 +    virtual InitialTimeZoneRule* clone(void) const;
   1.234 +
   1.235 +    /**
   1.236 +     * Assignment operator.
   1.237 +     * @param right The object to be copied.
   1.238 +     * @stable ICU 3.8
   1.239 +     */
   1.240 +    InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);
   1.241 +
   1.242 +    /**
   1.243 +     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
   1.244 +     * of different subclasses are considered unequal.
   1.245 +     * @param that  The object to be compared with.
   1.246 +     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.
   1.247 +     * @stable ICU 3.8
   1.248 +     */
   1.249 +    virtual UBool operator==(const TimeZoneRule& that) const;
   1.250 +
   1.251 +    /**
   1.252 +     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
   1.253 +     * of different subclasses are considered unequal.
   1.254 +     * @param that  The object to be compared with.
   1.255 +     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.
   1.256 +     * @stable ICU 3.8
   1.257 +     */
   1.258 +    virtual UBool operator!=(const TimeZoneRule& that) const;
   1.259 +
   1.260 +    /**
   1.261 +     * Gets the time when this rule takes effect in the given year.
   1.262 +     * @param year              The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
   1.263 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.264 +     *                          takes effect in milliseconds.
   1.265 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.266 +     *                          standard time.
   1.267 +     * @param result            Receives the start time in the year.
   1.268 +     * @return  true if this rule takes effect in the year and the result is set to
   1.269 +     *          "result".
   1.270 +     * @stable ICU 3.8
   1.271 +     */
   1.272 +    UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
   1.273 +
   1.274 +    /**
   1.275 +     * Returns if this rule represents the same rule and offsets as another.
   1.276 +     * When two <code>TimeZoneRule</code> objects differ only its names, this method
   1.277 +     * returns true.
   1.278 +     * @param that  The <code>TimeZoneRule</code> object to be compared with.
   1.279 +     * @return  true if the other <code>TimeZoneRule</code> is equivalent to this one.
   1.280 +     * @stable ICU 3.8
   1.281 +     */
   1.282 +    virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
   1.283 +
   1.284 +    /**
   1.285 +     * Gets the very first time when this rule takes effect.
   1.286 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.287 +     *                          takes effect in milliseconds.
   1.288 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.289 +     *                          standard time.
   1.290 +     * @param result            Receives the very first time when this rule takes effect.
   1.291 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.292 +     *          "result" is unchanged.
   1.293 +     * @stable ICU 3.8
   1.294 +     */
   1.295 +    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
   1.296 +
   1.297 +    /**
   1.298 +     * Gets the final time when this rule takes effect.
   1.299 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.300 +     *                          takes effect in milliseconds.
   1.301 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.302 +     *                          standard time.
   1.303 +     * @param result            Receives the final time when this rule takes effect.
   1.304 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.305 +     *          "result" is unchanged.
   1.306 +     * @stable ICU 3.8
   1.307 +     */
   1.308 +    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
   1.309 +
   1.310 +    /**
   1.311 +     * Gets the first time when this rule takes effect after the specified time.
   1.312 +     * @param base              The first start time after this base time will be returned.
   1.313 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.314 +     *                          takes effect in milliseconds.
   1.315 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.316 +     *                          standard time.
   1.317 +     * @param inclusive         Whether the base time is inclusive or not.
   1.318 +     * @param result            Receives The first time when this rule takes effect after
   1.319 +     *                          the specified base time.
   1.320 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.321 +     *          "result" is unchanged.
   1.322 +     * @stable ICU 3.8
   1.323 +     */
   1.324 +    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
   1.325 +        UBool inclusive, UDate& result) const;
   1.326 +
   1.327 +    /**
   1.328 +     * Gets the most recent time when this rule takes effect before the specified time.
   1.329 +     * @param base              The most recent time before this base time will be returned.
   1.330 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.331 +     *                          takes effect in milliseconds.
   1.332 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.333 +     *                          standard time.
   1.334 +     * @param inclusive         Whether the base time is inclusive or not.
   1.335 +     * @param result            Receives The most recent time when this rule takes effect before
   1.336 +     *                          the specified base time.
   1.337 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.338 +     *          "result" is unchanged.
   1.339 +     * @stable ICU 3.8
   1.340 +     */
   1.341 +    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
   1.342 +        UBool inclusive, UDate& result) const;
   1.343 +
   1.344 +public:
   1.345 +    /**
   1.346 +     * Return the class ID for this class. This is useful only for comparing to
   1.347 +     * a return value from getDynamicClassID(). For example:
   1.348 +     * <pre>
   1.349 +     * .   Base* polymorphic_pointer = createPolymorphicObject();
   1.350 +     * .   if (polymorphic_pointer->getDynamicClassID() ==
   1.351 +     * .       erived::getStaticClassID()) ...
   1.352 +     * </pre>
   1.353 +     * @return          The class ID for all objects of this class.
   1.354 +     * @stable ICU 3.8
   1.355 +     */
   1.356 +    static UClassID U_EXPORT2 getStaticClassID(void);
   1.357 +
   1.358 +    /**
   1.359 +     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
   1.360 +     * method is to implement a simple version of RTTI, since not all C++
   1.361 +     * compilers support genuine RTTI. Polymorphic operator==() and clone()
   1.362 +     * methods call this method.
   1.363 +     *
   1.364 +     * @return          The class ID for this object. All objects of a
   1.365 +     *                  given class have the same class ID.  Objects of
   1.366 +     *                  other classes have different class IDs.
   1.367 +     * @stable ICU 3.8
   1.368 +     */
   1.369 +    virtual UClassID getDynamicClassID(void) const;
   1.370 +};
   1.371 +
   1.372 +/**
   1.373 + * <code>AnnualTimeZoneRule</code> is a class used for representing a time zone
   1.374 + * rule which takes effect annually.  The calenday system used for the rule is
   1.375 + * is based on Gregorian calendar
   1.376 + * 
   1.377 + * @stable ICU 3.8
   1.378 + */
   1.379 +class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {
   1.380 +public:
   1.381 +    /**
   1.382 +     * The constant representing the maximum year used for designating
   1.383 +     * a rule is permanent.
   1.384 +     */
   1.385 +    static const int32_t MAX_YEAR;
   1.386 +
   1.387 +    /**
   1.388 +     * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its
   1.389 +     * standard time, the amount of daylight saving offset adjustment, the annual start
   1.390 +     * time rule and the start/until years.  The input DateTimeRule is copied by this
   1.391 +     * constructor, so the caller remains responsible for deleting the object.
   1.392 +     * @param name          The time zone name.
   1.393 +     * @param rawOffset     The GMT offset of its standard time in milliseconds.
   1.394 +     * @param dstSavings    The amount of daylight saving offset adjustment in
   1.395 +     *                      milliseconds.  If this ia a rule for standard time,
   1.396 +     *                      the value of this argument is 0.
   1.397 +     * @param dateTimeRule  The start date/time rule repeated annually.
   1.398 +     * @param startYear     The first year when this rule takes effect.
   1.399 +     * @param endYear       The last year when this rule takes effect.  If this
   1.400 +     *                      rule is effective forever in future, specify MAX_YEAR.
   1.401 +     * @stable ICU 3.8
   1.402 +     */
   1.403 +    AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
   1.404 +            const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
   1.405 +
   1.406 +    /**
   1.407 +     * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its
   1.408 +     * standard time, the amount of daylight saving offset adjustment, the annual start
   1.409 +     * time rule and the start/until years.  The input DateTimeRule object is adopted
   1.410 +     * by this object, therefore, the caller must not delete the object.
   1.411 +     * @param name          The time zone name.
   1.412 +     * @param rawOffset     The GMT offset of its standard time in milliseconds.
   1.413 +     * @param dstSavings    The amount of daylight saving offset adjustment in
   1.414 +     *                      milliseconds.  If this ia a rule for standard time,
   1.415 +     *                      the value of this argument is 0.
   1.416 +     * @param dateTimeRule  The start date/time rule repeated annually.
   1.417 +     * @param startYear     The first year when this rule takes effect.
   1.418 +     * @param endYear       The last year when this rule takes effect.  If this
   1.419 +     *                      rule is effective forever in future, specify MAX_YEAR.
   1.420 +     * @stable ICU 3.8
   1.421 +     */
   1.422 +    AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
   1.423 +            DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
   1.424 +
   1.425 +    /**
   1.426 +     * Copy constructor.
   1.427 +     * @param source    The AnnualTimeZoneRule object to be copied.
   1.428 +     * @stable ICU 3.8
   1.429 +     */
   1.430 +    AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
   1.431 +
   1.432 +    /**
   1.433 +     * Destructor.
   1.434 +     * @stable ICU 3.8
   1.435 +     */
   1.436 +    virtual ~AnnualTimeZoneRule();
   1.437 +
   1.438 +    /**
   1.439 +     * Clone this AnnualTimeZoneRule object polymorphically. The caller owns the result and
   1.440 +     * should delete it when done.
   1.441 +     * @return    A copy of the object.
   1.442 +     * @stable ICU 3.8
   1.443 +     */
   1.444 +    virtual AnnualTimeZoneRule* clone(void) const;
   1.445 +
   1.446 +    /**
   1.447 +     * Assignment operator.
   1.448 +     * @param right The object to be copied.
   1.449 +     * @stable ICU 3.8
   1.450 +     */
   1.451 +    AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);
   1.452 +
   1.453 +    /**
   1.454 +     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
   1.455 +     * of different subclasses are considered unequal.
   1.456 +     * @param that  The object to be compared with.
   1.457 +     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.
   1.458 +     * @stable ICU 3.8
   1.459 +     */
   1.460 +    virtual UBool operator==(const TimeZoneRule& that) const;
   1.461 +
   1.462 +    /**
   1.463 +     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
   1.464 +     * of different subclasses are considered unequal.
   1.465 +     * @param that  The object to be compared with.
   1.466 +     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.
   1.467 +     * @stable ICU 3.8
   1.468 +     */
   1.469 +    virtual UBool operator!=(const TimeZoneRule& that) const;
   1.470 +
   1.471 +    /**
   1.472 +     * Gets the start date/time rule used by this rule.
   1.473 +     * @return  The <code>AnnualDateTimeRule</code> which represents the start date/time
   1.474 +     *          rule used by this time zone rule.
   1.475 +     * @stable ICU 3.8
   1.476 +     */
   1.477 +    const DateTimeRule* getRule(void) const;
   1.478 +
   1.479 +    /**
   1.480 +     * Gets the first year when this rule takes effect.
   1.481 +     * @return  The start year of this rule.  The year is in Gregorian calendar
   1.482 +     *          with 0 == 1 BCE, -1 == 2 BCE, etc.
   1.483 +     * @stable ICU 3.8
   1.484 +     */
   1.485 +    int32_t getStartYear(void) const;
   1.486 +
   1.487 +    /**
   1.488 +     * Gets the end year when this rule takes effect.
   1.489 +     * @return  The end year of this rule (inclusive). The year is in Gregorian calendar
   1.490 +     *          with 0 == 1 BCE, -1 == 2 BCE, etc.
   1.491 +     * @stable ICU 3.8
   1.492 +     */
   1.493 +    int32_t getEndYear(void) const;
   1.494 +
   1.495 +    /**
   1.496 +     * Gets the time when this rule takes effect in the given year.
   1.497 +     * @param year              The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
   1.498 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.499 +     *                          takes effect in milliseconds.
   1.500 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.501 +     *                          standard time.
   1.502 +     * @param result            Receives the start time in the year.
   1.503 +     * @return  true if this rule takes effect in the year and the result is set to
   1.504 +     *          "result".
   1.505 +     * @stable ICU 3.8
   1.506 +     */
   1.507 +    UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
   1.508 +
   1.509 +    /**
   1.510 +     * Returns if this rule represents the same rule and offsets as another.
   1.511 +     * When two <code>TimeZoneRule</code> objects differ only its names, this method
   1.512 +     * returns true.
   1.513 +     * @param that  The <code>TimeZoneRule</code> object to be compared with.
   1.514 +     * @return  true if the other <code>TimeZoneRule</code> is equivalent to this one.
   1.515 +     * @stable ICU 3.8
   1.516 +     */
   1.517 +    virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
   1.518 +
   1.519 +    /**
   1.520 +     * Gets the very first time when this rule takes effect.
   1.521 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.522 +     *                          takes effect in milliseconds.
   1.523 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.524 +     *                          standard time.
   1.525 +     * @param result            Receives the very first time when this rule takes effect.
   1.526 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.527 +     *          "result" is unchanged.
   1.528 +     * @stable ICU 3.8
   1.529 +     */
   1.530 +    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
   1.531 +
   1.532 +    /**
   1.533 +     * Gets the final time when this rule takes effect.
   1.534 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.535 +     *                          takes effect in milliseconds.
   1.536 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.537 +     *                          standard time.
   1.538 +     * @param result            Receives the final time when this rule takes effect.
   1.539 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.540 +     *          "result" is unchanged.
   1.541 +     * @stable ICU 3.8
   1.542 +     */
   1.543 +    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
   1.544 +
   1.545 +    /**
   1.546 +     * Gets the first time when this rule takes effect after the specified time.
   1.547 +     * @param base              The first start time after this base time will be returned.
   1.548 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.549 +     *                          takes effect in milliseconds.
   1.550 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.551 +     *                          standard time.
   1.552 +     * @param inclusive         Whether the base time is inclusive or not.
   1.553 +     * @param result            Receives The first time when this rule takes effect after
   1.554 +     *                          the specified base time.
   1.555 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.556 +     *          "result" is unchanged.
   1.557 +     * @stable ICU 3.8
   1.558 +     */
   1.559 +    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
   1.560 +        UBool inclusive, UDate& result) const;
   1.561 +
   1.562 +    /**
   1.563 +     * Gets the most recent time when this rule takes effect before the specified time.
   1.564 +     * @param base              The most recent time before this base time will be returned.
   1.565 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.566 +     *                          takes effect in milliseconds.
   1.567 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.568 +     *                          standard time.
   1.569 +     * @param inclusive         Whether the base time is inclusive or not.
   1.570 +     * @param result            Receives The most recent time when this rule takes effect before
   1.571 +     *                          the specified base time.
   1.572 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.573 +     *          "result" is unchanged.
   1.574 +     * @stable ICU 3.8
   1.575 +     */
   1.576 +    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
   1.577 +        UBool inclusive, UDate& result) const;
   1.578 +
   1.579 +
   1.580 +private:
   1.581 +    DateTimeRule* fDateTimeRule;
   1.582 +    int32_t fStartYear;
   1.583 +    int32_t fEndYear;
   1.584 +
   1.585 +public:
   1.586 +    /**
   1.587 +     * Return the class ID for this class. This is useful only for comparing to
   1.588 +     * a return value from getDynamicClassID(). For example:
   1.589 +     * <pre>
   1.590 +     * .   Base* polymorphic_pointer = createPolymorphicObject();
   1.591 +     * .   if (polymorphic_pointer->getDynamicClassID() ==
   1.592 +     * .       erived::getStaticClassID()) ...
   1.593 +     * </pre>
   1.594 +     * @return          The class ID for all objects of this class.
   1.595 +     * @stable ICU 3.8
   1.596 +     */
   1.597 +    static UClassID U_EXPORT2 getStaticClassID(void);
   1.598 +
   1.599 +    /**
   1.600 +     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
   1.601 +     * method is to implement a simple version of RTTI, since not all C++
   1.602 +     * compilers support genuine RTTI. Polymorphic operator==() and clone()
   1.603 +     * methods call this method.
   1.604 +     *
   1.605 +     * @return          The class ID for this object. All objects of a
   1.606 +     *                  given class have the same class ID.  Objects of
   1.607 +     *                  other classes have different class IDs.
   1.608 +     * @stable ICU 3.8
   1.609 +     */
   1.610 +    virtual UClassID getDynamicClassID(void) const;
   1.611 +};
   1.612 +
   1.613 +/**
   1.614 + * <code>TimeArrayTimeZoneRule</code> represents a time zone rule whose start times are
   1.615 + * defined by an array of milliseconds since the standard base time.
   1.616 + * 
   1.617 + * @stable ICU 3.8
   1.618 + */
   1.619 +class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {
   1.620 +public:
   1.621 +    /**
   1.622 +     * Constructs a <code>TimeArrayTimeZoneRule</code> with the name, the GMT offset of its
   1.623 +     * standard time, the amount of daylight saving offset adjustment and
   1.624 +     * the array of times when this rule takes effect.
   1.625 +     * @param name          The time zone name.
   1.626 +     * @param rawOffset     The UTC offset of its standard time in milliseconds.
   1.627 +     * @param dstSavings    The amount of daylight saving offset adjustment in
   1.628 +     *                      milliseconds.  If this ia a rule for standard time,
   1.629 +     *                      the value of this argument is 0.
   1.630 +     * @param startTimes    The array start times in milliseconds since the base time
   1.631 +     *                      (January 1, 1970, 00:00:00).
   1.632 +     * @param numStartTimes The number of elements in the parameter "startTimes"
   1.633 +     * @param timeRuleType  The time type of the start times, which is one of
   1.634 +     *                      <code>DataTimeRule::WALL_TIME</code>, <code>STANDARD_TIME</code>
   1.635 +     *                      and <code>UTC_TIME</code>.
   1.636 +     * @stable ICU 3.8
   1.637 +     */
   1.638 +    TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
   1.639 +        const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
   1.640 +
   1.641 +    /**
   1.642 +     * Copy constructor.
   1.643 +     * @param source    The TimeArrayTimeZoneRule object to be copied.
   1.644 +     * @stable ICU 3.8
   1.645 +     */
   1.646 +    TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);
   1.647 +
   1.648 +    /**
   1.649 +     * Destructor.
   1.650 +     * @stable ICU 3.8
   1.651 +     */
   1.652 +    virtual ~TimeArrayTimeZoneRule();
   1.653 +
   1.654 +    /**
   1.655 +     * Clone this TimeArrayTimeZoneRule object polymorphically. The caller owns the result and
   1.656 +     * should delete it when done.
   1.657 +     * @return    A copy of the object.
   1.658 +     * @stable ICU 3.8
   1.659 +     */
   1.660 +    virtual TimeArrayTimeZoneRule* clone(void) const;
   1.661 +
   1.662 +    /**
   1.663 +     * Assignment operator.
   1.664 +     * @param right The object to be copied.
   1.665 +     * @stable ICU 3.8
   1.666 +     */
   1.667 +    TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);
   1.668 +
   1.669 +    /**
   1.670 +     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
   1.671 +     * of different subclasses are considered unequal.
   1.672 +     * @param that  The object to be compared with.
   1.673 +     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.
   1.674 +     * @stable ICU 3.8
   1.675 +     */
   1.676 +    virtual UBool operator==(const TimeZoneRule& that) const;
   1.677 +
   1.678 +    /**
   1.679 +     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
   1.680 +     * of different subclasses are considered unequal.
   1.681 +     * @param that  The object to be compared with.
   1.682 +     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.
   1.683 +     * @stable ICU 3.8
   1.684 +     */
   1.685 +    virtual UBool operator!=(const TimeZoneRule& that) const;
   1.686 +
   1.687 +    /**
   1.688 +     * Gets the time type of the start times used by this rule.  The return value
   1.689 +     * is either <code>DateTimeRule::WALL_TIME</code> or <code>STANDARD_TIME</code>
   1.690 +     * or <code>UTC_TIME</code>.
   1.691 +     * 
   1.692 +     * @return The time type used of the start times used by this rule.
   1.693 +     * @stable ICU 3.8
   1.694 +     */
   1.695 +    DateTimeRule::TimeRuleType getTimeType(void) const;
   1.696 +
   1.697 +    /**
   1.698 +     * Gets a start time at the index stored in this rule.
   1.699 +     * @param index     The index of start times
   1.700 +     * @param result    Receives the start time at the index
   1.701 +     * @return  true if the index is within the valid range and
   1.702 +     *          and the result is set.  When false, the output
   1.703 +     *          parameger "result" is unchanged.
   1.704 +     * @stable ICU 3.8
   1.705 +     */
   1.706 +    UBool getStartTimeAt(int32_t index, UDate& result) const;
   1.707 +
   1.708 +    /**
   1.709 +     * Returns the number of start times stored in this rule
   1.710 +     * @return The number of start times.
   1.711 +     * @stable ICU 3.8
   1.712 +     */
   1.713 +    int32_t countStartTimes(void) const;
   1.714 +
   1.715 +    /**
   1.716 +     * Returns if this rule represents the same rule and offsets as another.
   1.717 +     * When two <code>TimeZoneRule</code> objects differ only its names, this method
   1.718 +     * returns true.
   1.719 +     * @param that  The <code>TimeZoneRule</code> object to be compared with.
   1.720 +     * @return  true if the other <code>TimeZoneRule</code> is equivalent to this one.
   1.721 +     * @stable ICU 3.8
   1.722 +     */
   1.723 +    virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
   1.724 +
   1.725 +    /**
   1.726 +     * Gets the very first time when this rule takes effect.
   1.727 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.728 +     *                          takes effect in milliseconds.
   1.729 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.730 +     *                          standard time.
   1.731 +     * @param result            Receives the very first time when this rule takes effect.
   1.732 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.733 +     *          "result" is unchanged.
   1.734 +     * @stable ICU 3.8
   1.735 +     */
   1.736 +    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
   1.737 +
   1.738 +    /**
   1.739 +     * Gets the final time when this rule takes effect.
   1.740 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.741 +     *                          takes effect in milliseconds.
   1.742 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.743 +     *                          standard time.
   1.744 +     * @param result            Receives the final time when this rule takes effect.
   1.745 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.746 +     *          "result" is unchanged.
   1.747 +     * @stable ICU 3.8
   1.748 +     */
   1.749 +    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
   1.750 +
   1.751 +    /**
   1.752 +     * Gets the first time when this rule takes effect after the specified time.
   1.753 +     * @param base              The first start time after this base time will be returned.
   1.754 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.755 +     *                          takes effect in milliseconds.
   1.756 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.757 +     *                          standard time.
   1.758 +     * @param inclusive         Whether the base time is inclusive or not.
   1.759 +     * @param result            Receives The first time when this rule takes effect after
   1.760 +     *                          the specified base time.
   1.761 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.762 +     *          "result" is unchanged.
   1.763 +     * @stable ICU 3.8
   1.764 +     */
   1.765 +    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
   1.766 +        UBool inclusive, UDate& result) const;
   1.767 +
   1.768 +    /**
   1.769 +     * Gets the most recent time when this rule takes effect before the specified time.
   1.770 +     * @param base              The most recent time before this base time will be returned.
   1.771 +     * @param prevRawOffset     The standard time offset from UTC before this rule
   1.772 +     *                          takes effect in milliseconds.
   1.773 +     * @param prevDSTSavings    The amount of daylight saving offset from the
   1.774 +     *                          standard time.
   1.775 +     * @param inclusive         Whether the base time is inclusive or not.
   1.776 +     * @param result            Receives The most recent time when this rule takes effect before
   1.777 +     *                          the specified base time.
   1.778 +     * @return  true if the start time is available.  When false is returned, output parameter
   1.779 +     *          "result" is unchanged.
   1.780 +     * @stable ICU 3.8
   1.781 +     */
   1.782 +    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
   1.783 +        UBool inclusive, UDate& result) const;
   1.784 +
   1.785 +
   1.786 +private:
   1.787 +    enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
   1.788 +    UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
   1.789 +    UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
   1.790 +
   1.791 +    DateTimeRule::TimeRuleType  fTimeRuleType;
   1.792 +    int32_t fNumStartTimes;
   1.793 +    UDate*  fStartTimes;
   1.794 +    UDate   fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
   1.795 +
   1.796 +public:
   1.797 +    /**
   1.798 +     * Return the class ID for this class. This is useful only for comparing to
   1.799 +     * a return value from getDynamicClassID(). For example:
   1.800 +     * <pre>
   1.801 +     * .   Base* polymorphic_pointer = createPolymorphicObject();
   1.802 +     * .   if (polymorphic_pointer->getDynamicClassID() ==
   1.803 +     * .       erived::getStaticClassID()) ...
   1.804 +     * </pre>
   1.805 +     * @return          The class ID for all objects of this class.
   1.806 +     * @stable ICU 3.8
   1.807 +     */
   1.808 +    static UClassID U_EXPORT2 getStaticClassID(void);
   1.809 +
   1.810 +    /**
   1.811 +     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
   1.812 +     * method is to implement a simple version of RTTI, since not all C++
   1.813 +     * compilers support genuine RTTI. Polymorphic operator==() and clone()
   1.814 +     * methods call this method.
   1.815 +     *
   1.816 +     * @return          The class ID for this object. All objects of a
   1.817 +     *                  given class have the same class ID.  Objects of
   1.818 +     *                  other classes have different class IDs.
   1.819 +     * @stable ICU 3.8
   1.820 +     */
   1.821 +    virtual UClassID getDynamicClassID(void) const;
   1.822 +};
   1.823 +
   1.824 +
   1.825 +U_NAMESPACE_END
   1.826 +
   1.827 +#endif /* #if !UCONFIG_NO_FORMATTING */
   1.828 +
   1.829 +#endif // TZRULE_H
   1.830 +
   1.831 +//eof

mercurial