michael@0: /*
michael@0: *******************************************************************************
michael@0: * Copyright (C) 2007-2008, International Business Machines Corporation and *
michael@0: * others. All Rights Reserved. *
michael@0: *******************************************************************************
michael@0: */
michael@0: #ifndef TZRULE_H
michael@0: #define TZRULE_H
michael@0:
michael@0: /**
michael@0: * \file
michael@0: * \brief C++ API: Time zone rule 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 "unicode/unistr.h"
michael@0: #include "unicode/dtrule.h"
michael@0:
michael@0: U_NAMESPACE_BEGIN
michael@0:
michael@0: /**
michael@0: * TimeZoneRule
is a class representing a rule for time zone.
michael@0: * TimeZoneRule
has a set of time zone attributes, such as zone name,
michael@0: * raw offset (UTC offset for standard time) and daylight saving time offset.
michael@0: *
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: class U_I18N_API TimeZoneRule : public UObject {
michael@0: public:
michael@0: /**
michael@0: * Destructor.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual ~TimeZoneRule();
michael@0:
michael@0: /**
michael@0: * Clone this TimeZoneRule object polymorphically. The caller owns the result and
michael@0: * should delete it when done.
michael@0: * @return A copy of the object.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual TimeZoneRule* clone(void) const = 0;
michael@0:
michael@0: /**
michael@0: * Return true if the given TimeZoneRule
objects are semantically equal. Objects
michael@0: * of different subclasses are considered unequal.
michael@0: * @param that The object to be compared with.
michael@0: * @return true if the given TimeZoneRule
objects are semantically equal.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool operator==(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Return true if the given TimeZoneRule
objects are semantically unequal. Objects
michael@0: * of different subclasses are considered unequal.
michael@0: * @param that The object to be compared with.
michael@0: * @return true if the given TimeZoneRule
objects are semantically unequal.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool operator!=(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Fills in "name" with the name of this time zone.
michael@0: * @param name Receives the name of this time zone.
michael@0: * @return A reference to "name"
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: UnicodeString& getName(UnicodeString& name) const;
michael@0:
michael@0: /**
michael@0: * Gets the standard time offset.
michael@0: * @return The standard time offset from UTC in milliseconds.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: int32_t getRawOffset(void) const;
michael@0:
michael@0: /**
michael@0: * Gets the amount of daylight saving delta time from the standard time.
michael@0: * @return The amount of daylight saving offset used by this rule
michael@0: * in milliseconds.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: int32_t getDSTSavings(void) const;
michael@0:
michael@0: /**
michael@0: * Returns if this rule represents the same rule and offsets as another.
michael@0: * When two TimeZoneRule
objects differ only its names, this method
michael@0: * returns true.
michael@0: * @param other The TimeZoneRule
object to be compared with.
michael@0: * @return true if the other TimeZoneRule
is the same as this one.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
michael@0:
michael@0: /**
michael@0: * Gets the very first time when this rule takes effect.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param result Receives the very first time when this rule takes effect.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
michael@0:
michael@0: /**
michael@0: * Gets the final time when this rule takes effect.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param result Receives the final time when this rule takes effect.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
michael@0:
michael@0: /**
michael@0: * Gets the first time when this rule takes effect after the specified time.
michael@0: * @param base The first start time after this base time will be returned.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param inclusive Whether the base time is inclusive or not.
michael@0: * @param result Receives The first time when this rule takes effect after
michael@0: * the specified base time.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
michael@0: UBool inclusive, UDate& result) const = 0;
michael@0:
michael@0: /**
michael@0: * Gets the most recent time when this rule takes effect before the specified time.
michael@0: * @param base The most recent time before this base time will be returned.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param inclusive Whether the base time is inclusive or not.
michael@0: * @param result Receives The most recent time when this rule takes effect before
michael@0: * the specified base time.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
michael@0: UBool inclusive, UDate& result) const = 0;
michael@0:
michael@0: protected:
michael@0:
michael@0: /**
michael@0: * Constructs a TimeZoneRule
with the name, the GMT offset of its
michael@0: * standard time and the amount of daylight saving offset adjustment.
michael@0: * @param name The time zone name.
michael@0: * @param rawOffset The UTC offset of its standard time in milliseconds.
michael@0: * @param dstSavings The amount of daylight saving offset adjustment in milliseconds.
michael@0: * If this ia a rule for standard time, the value of this argument is 0.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
michael@0:
michael@0: /**
michael@0: * Copy constructor.
michael@0: * @param source The TimeZoneRule object to be copied.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeZoneRule(const TimeZoneRule& source);
michael@0:
michael@0: /**
michael@0: * Assignment operator.
michael@0: * @param right The object to be copied.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeZoneRule& operator=(const TimeZoneRule& right);
michael@0:
michael@0: private:
michael@0: UnicodeString fName; // time name
michael@0: int32_t fRawOffset; // UTC offset of the standard time in milliseconds
michael@0: int32_t fDSTSavings; // DST saving amount in milliseconds
michael@0: };
michael@0:
michael@0: /**
michael@0: * InitialTimeZoneRule
represents a time zone rule
michael@0: * representing a time zone effective from the beginning and
michael@0: * has no actual start times.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: class U_I18N_API InitialTimeZoneRule : public TimeZoneRule {
michael@0: public:
michael@0: /**
michael@0: * Constructs an InitialTimeZoneRule
with the name, the GMT offset of its
michael@0: * standard time and the amount of daylight saving offset adjustment.
michael@0: * @param name The time zone name.
michael@0: * @param rawOffset The UTC offset of its standard time in milliseconds.
michael@0: * @param dstSavings The amount of daylight saving offset adjustment in milliseconds.
michael@0: * If this ia a rule for standard time, the value of this argument is 0.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
michael@0:
michael@0: /**
michael@0: * Copy constructor.
michael@0: * @param source The InitialTimeZoneRule object to be copied.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: InitialTimeZoneRule(const InitialTimeZoneRule& source);
michael@0:
michael@0: /**
michael@0: * Destructor.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual ~InitialTimeZoneRule();
michael@0:
michael@0: /**
michael@0: * Clone this InitialTimeZoneRule object polymorphically. The caller owns the result and
michael@0: * should delete it when done.
michael@0: * @return A copy of the object.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual InitialTimeZoneRule* clone(void) const;
michael@0:
michael@0: /**
michael@0: * Assignment operator.
michael@0: * @param right The object to be copied.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);
michael@0:
michael@0: /**
michael@0: * Return true if the given TimeZoneRule
objects are semantically equal. Objects
michael@0: * of different subclasses are considered unequal.
michael@0: * @param that The object to be compared with.
michael@0: * @return true if the given TimeZoneRule
objects are semantically equal.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool operator==(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Return true if the given TimeZoneRule
objects are semantically unequal. Objects
michael@0: * of different subclasses are considered unequal.
michael@0: * @param that The object to be compared with.
michael@0: * @return true if the given TimeZoneRule
objects are semantically unequal.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool operator!=(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Gets the time when this rule takes effect in the given year.
michael@0: * @param year The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param result Receives the start time in the year.
michael@0: * @return true if this rule takes effect in the year and the result is set to
michael@0: * "result".
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Returns if this rule represents the same rule and offsets as another.
michael@0: * When two TimeZoneRule
objects differ only its names, this method
michael@0: * returns true.
michael@0: * @param that The TimeZoneRule
object to be compared with.
michael@0: * @return true if the other TimeZoneRule
is equivalent to this one.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Gets the very first time when this rule takes effect.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param result Receives the very first time when this rule takes effect.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Gets the final time when this rule takes effect.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param result Receives the final time when this rule takes effect.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Gets the first time when this rule takes effect after the specified time.
michael@0: * @param base The first start time after this base time will be returned.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param inclusive Whether the base time is inclusive or not.
michael@0: * @param result Receives The first time when this rule takes effect after
michael@0: * the specified base time.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
michael@0: UBool inclusive, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Gets the most recent time when this rule takes effect before the specified time.
michael@0: * @param base The most recent time before this base time will be returned.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param inclusive Whether the base time is inclusive or not.
michael@0: * @param result Receives The most recent time when this rule takes effect before
michael@0: * the specified base time.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
michael@0: UBool inclusive, UDate& result) const;
michael@0:
michael@0: public:
michael@0: /**
michael@0: * Return the class ID for this class. This is useful only for comparing to
michael@0: * a return value from getDynamicClassID(). For example:
michael@0: *
michael@0: * . Base* polymorphic_pointer = createPolymorphicObject(); michael@0: * . if (polymorphic_pointer->getDynamicClassID() == michael@0: * . erived::getStaticClassID()) ... michael@0: *michael@0: * @return The class ID for all objects of this class. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: static UClassID U_EXPORT2 getStaticClassID(void); michael@0: michael@0: /** michael@0: * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This michael@0: * method is to implement a simple version of RTTI, since not all C++ michael@0: * compilers support genuine RTTI. Polymorphic operator==() and clone() michael@0: * methods call this method. michael@0: * michael@0: * @return The class ID for this object. All objects of a michael@0: * given class have the same class ID. Objects of michael@0: * other classes have different class IDs. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: virtual UClassID getDynamicClassID(void) const; michael@0: }; michael@0: michael@0: /** michael@0: *
AnnualTimeZoneRule
is a class used for representing a time zone
michael@0: * rule which takes effect annually. The calenday system used for the rule is
michael@0: * is based on Gregorian calendar
michael@0: *
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {
michael@0: public:
michael@0: /**
michael@0: * The constant representing the maximum year used for designating
michael@0: * a rule is permanent.
michael@0: */
michael@0: static const int32_t MAX_YEAR;
michael@0:
michael@0: /**
michael@0: * Constructs a AnnualTimeZoneRule
with the name, the GMT offset of its
michael@0: * standard time, the amount of daylight saving offset adjustment, the annual start
michael@0: * time rule and the start/until years. The input DateTimeRule is copied by this
michael@0: * constructor, so the caller remains responsible for deleting the object.
michael@0: * @param name The time zone name.
michael@0: * @param rawOffset The GMT offset of its standard time in milliseconds.
michael@0: * @param dstSavings The amount of daylight saving offset adjustment in
michael@0: * milliseconds. If this ia a rule for standard time,
michael@0: * the value of this argument is 0.
michael@0: * @param dateTimeRule The start date/time rule repeated annually.
michael@0: * @param startYear The first year when this rule takes effect.
michael@0: * @param endYear The last year when this rule takes effect. If this
michael@0: * rule is effective forever in future, specify MAX_YEAR.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
michael@0: const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
michael@0:
michael@0: /**
michael@0: * Constructs a AnnualTimeZoneRule
with the name, the GMT offset of its
michael@0: * standard time, the amount of daylight saving offset adjustment, the annual start
michael@0: * time rule and the start/until years. The input DateTimeRule object is adopted
michael@0: * by this object, therefore, the caller must not delete the object.
michael@0: * @param name The time zone name.
michael@0: * @param rawOffset The GMT offset of its standard time in milliseconds.
michael@0: * @param dstSavings The amount of daylight saving offset adjustment in
michael@0: * milliseconds. If this ia a rule for standard time,
michael@0: * the value of this argument is 0.
michael@0: * @param dateTimeRule The start date/time rule repeated annually.
michael@0: * @param startYear The first year when this rule takes effect.
michael@0: * @param endYear The last year when this rule takes effect. If this
michael@0: * rule is effective forever in future, specify MAX_YEAR.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
michael@0: DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
michael@0:
michael@0: /**
michael@0: * Copy constructor.
michael@0: * @param source The AnnualTimeZoneRule object to be copied.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
michael@0:
michael@0: /**
michael@0: * Destructor.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual ~AnnualTimeZoneRule();
michael@0:
michael@0: /**
michael@0: * Clone this AnnualTimeZoneRule object polymorphically. The caller owns the result and
michael@0: * should delete it when done.
michael@0: * @return A copy of the object.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual AnnualTimeZoneRule* clone(void) const;
michael@0:
michael@0: /**
michael@0: * Assignment operator.
michael@0: * @param right The object to be copied.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);
michael@0:
michael@0: /**
michael@0: * Return true if the given TimeZoneRule
objects are semantically equal. Objects
michael@0: * of different subclasses are considered unequal.
michael@0: * @param that The object to be compared with.
michael@0: * @return true if the given TimeZoneRule
objects are semantically equal.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool operator==(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Return true if the given TimeZoneRule
objects are semantically unequal. Objects
michael@0: * of different subclasses are considered unequal.
michael@0: * @param that The object to be compared with.
michael@0: * @return true if the given TimeZoneRule
objects are semantically unequal.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool operator!=(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Gets the start date/time rule used by this rule.
michael@0: * @return The AnnualDateTimeRule
which represents the start date/time
michael@0: * rule used by this time zone rule.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: const DateTimeRule* getRule(void) const;
michael@0:
michael@0: /**
michael@0: * Gets the first year when this rule takes effect.
michael@0: * @return The start year of this rule. The year is in Gregorian calendar
michael@0: * with 0 == 1 BCE, -1 == 2 BCE, etc.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: int32_t getStartYear(void) const;
michael@0:
michael@0: /**
michael@0: * Gets the end year when this rule takes effect.
michael@0: * @return The end year of this rule (inclusive). The year is in Gregorian calendar
michael@0: * with 0 == 1 BCE, -1 == 2 BCE, etc.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: int32_t getEndYear(void) const;
michael@0:
michael@0: /**
michael@0: * Gets the time when this rule takes effect in the given year.
michael@0: * @param year The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param result Receives the start time in the year.
michael@0: * @return true if this rule takes effect in the year and the result is set to
michael@0: * "result".
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Returns if this rule represents the same rule and offsets as another.
michael@0: * When two TimeZoneRule
objects differ only its names, this method
michael@0: * returns true.
michael@0: * @param that The TimeZoneRule
object to be compared with.
michael@0: * @return true if the other TimeZoneRule
is equivalent to this one.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Gets the very first time when this rule takes effect.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param result Receives the very first time when this rule takes effect.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Gets the final time when this rule takes effect.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param result Receives the final time when this rule takes effect.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Gets the first time when this rule takes effect after the specified time.
michael@0: * @param base The first start time after this base time will be returned.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param inclusive Whether the base time is inclusive or not.
michael@0: * @param result Receives The first time when this rule takes effect after
michael@0: * the specified base time.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
michael@0: UBool inclusive, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Gets the most recent time when this rule takes effect before the specified time.
michael@0: * @param base The most recent time before this base time will be returned.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param inclusive Whether the base time is inclusive or not.
michael@0: * @param result Receives The most recent time when this rule takes effect before
michael@0: * the specified base time.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
michael@0: UBool inclusive, UDate& result) const;
michael@0:
michael@0:
michael@0: private:
michael@0: DateTimeRule* fDateTimeRule;
michael@0: int32_t fStartYear;
michael@0: int32_t fEndYear;
michael@0:
michael@0: public:
michael@0: /**
michael@0: * Return the class ID for this class. This is useful only for comparing to
michael@0: * a return value from getDynamicClassID(). For example:
michael@0: * michael@0: * . Base* polymorphic_pointer = createPolymorphicObject(); michael@0: * . if (polymorphic_pointer->getDynamicClassID() == michael@0: * . erived::getStaticClassID()) ... michael@0: *michael@0: * @return The class ID for all objects of this class. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: static UClassID U_EXPORT2 getStaticClassID(void); michael@0: michael@0: /** michael@0: * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This michael@0: * method is to implement a simple version of RTTI, since not all C++ michael@0: * compilers support genuine RTTI. Polymorphic operator==() and clone() michael@0: * methods call this method. michael@0: * michael@0: * @return The class ID for this object. All objects of a michael@0: * given class have the same class ID. Objects of michael@0: * other classes have different class IDs. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: virtual UClassID getDynamicClassID(void) const; michael@0: }; michael@0: michael@0: /** michael@0: *
TimeArrayTimeZoneRule
represents a time zone rule whose start times are
michael@0: * defined by an array of milliseconds since the standard base time.
michael@0: *
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {
michael@0: public:
michael@0: /**
michael@0: * Constructs a TimeArrayTimeZoneRule
with the name, the GMT offset of its
michael@0: * standard time, the amount of daylight saving offset adjustment and
michael@0: * the array of times when this rule takes effect.
michael@0: * @param name The time zone name.
michael@0: * @param rawOffset The UTC offset of its standard time in milliseconds.
michael@0: * @param dstSavings The amount of daylight saving offset adjustment in
michael@0: * milliseconds. If this ia a rule for standard time,
michael@0: * the value of this argument is 0.
michael@0: * @param startTimes The array start times in milliseconds since the base time
michael@0: * (January 1, 1970, 00:00:00).
michael@0: * @param numStartTimes The number of elements in the parameter "startTimes"
michael@0: * @param timeRuleType The time type of the start times, which is one of
michael@0: * DataTimeRule::WALL_TIME
, STANDARD_TIME
michael@0: * and UTC_TIME
.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
michael@0: const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
michael@0:
michael@0: /**
michael@0: * Copy constructor.
michael@0: * @param source The TimeArrayTimeZoneRule object to be copied.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);
michael@0:
michael@0: /**
michael@0: * Destructor.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual ~TimeArrayTimeZoneRule();
michael@0:
michael@0: /**
michael@0: * Clone this TimeArrayTimeZoneRule object polymorphically. The caller owns the result and
michael@0: * should delete it when done.
michael@0: * @return A copy of the object.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual TimeArrayTimeZoneRule* clone(void) const;
michael@0:
michael@0: /**
michael@0: * Assignment operator.
michael@0: * @param right The object to be copied.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);
michael@0:
michael@0: /**
michael@0: * Return true if the given TimeZoneRule
objects are semantically equal. Objects
michael@0: * of different subclasses are considered unequal.
michael@0: * @param that The object to be compared with.
michael@0: * @return true if the given TimeZoneRule
objects are semantically equal.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool operator==(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Return true if the given TimeZoneRule
objects are semantically unequal. Objects
michael@0: * of different subclasses are considered unequal.
michael@0: * @param that The object to be compared with.
michael@0: * @return true if the given TimeZoneRule
objects are semantically unequal.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool operator!=(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Gets the time type of the start times used by this rule. The return value
michael@0: * is either DateTimeRule::WALL_TIME
or STANDARD_TIME
michael@0: * or UTC_TIME
.
michael@0: *
michael@0: * @return The time type used of the start times used by this rule.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: DateTimeRule::TimeRuleType getTimeType(void) const;
michael@0:
michael@0: /**
michael@0: * Gets a start time at the index stored in this rule.
michael@0: * @param index The index of start times
michael@0: * @param result Receives the start time at the index
michael@0: * @return true if the index is within the valid range and
michael@0: * and the result is set. When false, the output
michael@0: * parameger "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: UBool getStartTimeAt(int32_t index, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Returns the number of start times stored in this rule
michael@0: * @return The number of start times.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: int32_t countStartTimes(void) const;
michael@0:
michael@0: /**
michael@0: * Returns if this rule represents the same rule and offsets as another.
michael@0: * When two TimeZoneRule
objects differ only its names, this method
michael@0: * returns true.
michael@0: * @param that The TimeZoneRule
object to be compared with.
michael@0: * @return true if the other TimeZoneRule
is equivalent to this one.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
michael@0:
michael@0: /**
michael@0: * Gets the very first time when this rule takes effect.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param result Receives the very first time when this rule takes effect.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Gets the final time when this rule takes effect.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param result Receives the final time when this rule takes effect.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Gets the first time when this rule takes effect after the specified time.
michael@0: * @param base The first start time after this base time will be returned.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param inclusive Whether the base time is inclusive or not.
michael@0: * @param result Receives The first time when this rule takes effect after
michael@0: * the specified base time.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
michael@0: UBool inclusive, UDate& result) const;
michael@0:
michael@0: /**
michael@0: * Gets the most recent time when this rule takes effect before the specified time.
michael@0: * @param base The most recent time before this base time will be returned.
michael@0: * @param prevRawOffset The standard time offset from UTC before this rule
michael@0: * takes effect in milliseconds.
michael@0: * @param prevDSTSavings The amount of daylight saving offset from the
michael@0: * standard time.
michael@0: * @param inclusive Whether the base time is inclusive or not.
michael@0: * @param result Receives The most recent time when this rule takes effect before
michael@0: * the specified base time.
michael@0: * @return true if the start time is available. When false is returned, output parameter
michael@0: * "result" is unchanged.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
michael@0: UBool inclusive, UDate& result) const;
michael@0:
michael@0:
michael@0: private:
michael@0: enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
michael@0: UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
michael@0: UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
michael@0:
michael@0: DateTimeRule::TimeRuleType fTimeRuleType;
michael@0: int32_t fNumStartTimes;
michael@0: UDate* fStartTimes;
michael@0: UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
michael@0:
michael@0: public:
michael@0: /**
michael@0: * Return the class ID for this class. This is useful only for comparing to
michael@0: * a return value from getDynamicClassID(). For example:
michael@0: * michael@0: * . Base* polymorphic_pointer = createPolymorphicObject(); michael@0: * . if (polymorphic_pointer->getDynamicClassID() == michael@0: * . erived::getStaticClassID()) ... michael@0: *michael@0: * @return The class ID for all objects of this class. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: static UClassID U_EXPORT2 getStaticClassID(void); michael@0: michael@0: /** michael@0: * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This michael@0: * method is to implement a simple version of RTTI, since not all C++ michael@0: * compilers support genuine RTTI. Polymorphic operator==() and clone() michael@0: * methods call this method. michael@0: * michael@0: * @return The class ID for this object. All objects of a michael@0: * given class have the same class ID. Objects of michael@0: * other classes have different class IDs. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: virtual UClassID getDynamicClassID(void) const; michael@0: }; michael@0: michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */ michael@0: michael@0: #endif // TZRULE_H michael@0: michael@0: //eof