Loading...
Searching...
No Matches
tzrule.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2007-2008, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
#ifndef TZRULE_H
#define TZRULE_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_FORMATTING
#include "unicode/uobject.h"
#include "unicode/unistr.h"
#include "unicode/dtrule.h"
U_NAMESPACE_BEGIN
class U_I18N_API TimeZoneRule : public UObject {
public:
virtual ~TimeZoneRule();
virtual TimeZoneRule* clone() const = 0;
virtual bool operator==(const TimeZoneRule& that) const;
virtual bool operator!=(const TimeZoneRule& that) const;
UnicodeString& getName(UnicodeString& name) const;
int32_t getRawOffset() const;
int32_t getDSTSavings() const;
virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
UBool inclusive, UDate& result) const = 0;
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
UBool inclusive, UDate& result) const = 0;
protected:
TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
TimeZoneRule(const TimeZoneRule& source);
TimeZoneRule& operator=(const TimeZoneRule& right);
private:
UnicodeString fName; // time name
int32_t fRawOffset; // UTC offset of the standard time in milliseconds
int32_t fDSTSavings; // DST saving amount in milliseconds
};
class U_I18N_API InitialTimeZoneRule : public TimeZoneRule {
public:
InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
InitialTimeZoneRule(const InitialTimeZoneRule& source);
virtual ~InitialTimeZoneRule();
virtual InitialTimeZoneRule* clone() const override;
InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);
virtual bool operator==(const TimeZoneRule& that) const override;
virtual bool operator!=(const TimeZoneRule& that) const override;
virtual UBool isEquivalentTo(const TimeZoneRule& that) const override;
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override;
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override;
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
UBool inclusive, UDate& result) const override;
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
UBool inclusive, UDate& result) const override;
public:
static UClassID U_EXPORT2 getStaticClassID();
virtual UClassID getDynamicClassID() const override;
};
class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {
public:
static const int32_t MAX_YEAR;
AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
virtual ~AnnualTimeZoneRule();
virtual AnnualTimeZoneRule* clone() const override;
AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);
virtual bool operator==(const TimeZoneRule& that) const override;
virtual bool operator!=(const TimeZoneRule& that) const override;
const DateTimeRule* getRule() const;
int32_t getStartYear() const;
int32_t getEndYear() const;
UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
virtual UBool isEquivalentTo(const TimeZoneRule& that) const override;
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override;
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override;
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
UBool inclusive, UDate& result) const override;
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
UBool inclusive, UDate& result) const override;
private:
DateTimeRule* fDateTimeRule;
int32_t fStartYear;
int32_t fEndYear;
public:
static UClassID U_EXPORT2 getStaticClassID();
virtual UClassID getDynamicClassID() const override;
};
class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {
public:
TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);
virtual ~TimeArrayTimeZoneRule();
virtual TimeArrayTimeZoneRule* clone() const override;
TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);
virtual bool operator==(const TimeZoneRule& that) const override;
virtual bool operator!=(const TimeZoneRule& that) const override;
DateTimeRule::TimeRuleType getTimeType() const;
UBool getStartTimeAt(int32_t index, UDate& result) const;
int32_t countStartTimes() const;
virtual UBool isEquivalentTo(const TimeZoneRule& that) const override;
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override;
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override;
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
UBool inclusive, UDate& result) const override;
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
UBool inclusive, UDate& result) const override;
private:
enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
DateTimeRule::TimeRuleType fTimeRuleType;
int32_t fNumStartTimes;
UDate* fStartTimes;
UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
public:
static UClassID U_EXPORT2 getStaticClassID();
virtual UClassID getDynamicClassID() const override;
};
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // TZRULE_H
//eof
icu::AnnualTimeZoneRule::~AnnualTimeZoneRule
virtual ~AnnualTimeZoneRule()
Destructor.
icu::AnnualTimeZoneRule::AnnualTimeZoneRule
AnnualTimeZoneRule(const UnicodeString &name, int32_t rawOffset, int32_t dstSavings, DateTimeRule *dateTimeRule, int32_t startYear, int32_t endYear)
Constructs a AnnualTimeZoneRule with the name, the GMT offset of its standard time,...
icu::AnnualTimeZoneRule::MAX_YEAR
static const int32_t MAX_YEAR
The constant representing the maximum year used for designating a rule is permanent.
Definition tzrule.h:372
icu::AnnualTimeZoneRule::operator=
AnnualTimeZoneRule & operator=(const AnnualTimeZoneRule &right)
Assignment operator.
icu::AnnualTimeZoneRule::getNextStart
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const override
Gets the first time when this rule takes effect after the specified time.
icu::AnnualTimeZoneRule::getEndYear
int32_t getEndYear() const
Gets the end year when this rule takes effect.
icu::AnnualTimeZoneRule::getStartInYear
UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the time when this rule takes effect in the given year.
icu::AnnualTimeZoneRule::AnnualTimeZoneRule
AnnualTimeZoneRule(const UnicodeString &name, int32_t rawOffset, int32_t dstSavings, const DateTimeRule &dateTimeRule, int32_t startYear, int32_t endYear)
Constructs a AnnualTimeZoneRule with the name, the GMT offset of its standard time,...
icu::AnnualTimeZoneRule::getRule
const DateTimeRule * getRule() const
Gets the start date/time rule used by this rule.
icu::AnnualTimeZoneRule::isEquivalentTo
virtual UBool isEquivalentTo(const TimeZoneRule &that) const override
Returns if this rule represents the same rule and offsets as another.
icu::AnnualTimeZoneRule::getStartYear
int32_t getStartYear() const
Gets the first year when this rule takes effect.
icu::AnnualTimeZoneRule::getDynamicClassID
virtual UClassID getDynamicClassID() const override
Returns a unique class ID POLYMORPHICALLY.
icu::AnnualTimeZoneRule::getFirstStart
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const override
Gets the very first time when this rule takes effect.
icu::AnnualTimeZoneRule::getFinalStart
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const override
Gets the final time when this rule takes effect.
icu::AnnualTimeZoneRule::clone
virtual AnnualTimeZoneRule * clone() const override
Clone this AnnualTimeZoneRule object polymorphically.
icu::AnnualTimeZoneRule::getStaticClassID
static UClassID getStaticClassID()
Return the class ID for this class.
icu::AnnualTimeZoneRule::operator==
virtual bool operator==(const TimeZoneRule &that) const override
Return true if the given TimeZoneRule objects are semantically equal.
icu::AnnualTimeZoneRule::operator!=
virtual bool operator!=(const TimeZoneRule &that) const override
Return true if the given TimeZoneRule objects are semantically unequal.
icu::AnnualTimeZoneRule::getPreviousStart
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const override
Gets the most recent time when this rule takes effect before the specified time.
icu::AnnualTimeZoneRule::AnnualTimeZoneRule
AnnualTimeZoneRule(const AnnualTimeZoneRule &source)
Copy constructor.
icu::DateTimeRule
DateTimeRule is a class representing a time in a year by a rule specified by month,...
Definition dtrule.h:33
icu::DateTimeRule::TimeRuleType
TimeRuleType
Time rule type constants.
Definition dtrule.h:55
icu::InitialTimeZoneRule::InitialTimeZoneRule
InitialTimeZoneRule(const UnicodeString &name, int32_t rawOffset, int32_t dstSavings)
Constructs an InitialTimeZoneRule with the name, the GMT offset of its standard time and the amount o...
icu::InitialTimeZoneRule::operator==
virtual bool operator==(const TimeZoneRule &that) const override
Return true if the given TimeZoneRule objects are semantically equal.
icu::InitialTimeZoneRule::getStaticClassID
static UClassID getStaticClassID()
Return the class ID for this class.
icu::InitialTimeZoneRule::getNextStart
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const override
Gets the first time when this rule takes effect after the specified time.
icu::InitialTimeZoneRule::clone
virtual InitialTimeZoneRule * clone() const override
Clone this InitialTimeZoneRule object polymorphically.
icu::InitialTimeZoneRule::getDynamicClassID
virtual UClassID getDynamicClassID() const override
Returns a unique class ID POLYMORPHICALLY.
icu::InitialTimeZoneRule::getFinalStart
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const override
Gets the final time when this rule takes effect.
icu::InitialTimeZoneRule::operator=
InitialTimeZoneRule & operator=(const InitialTimeZoneRule &right)
Assignment operator.
icu::InitialTimeZoneRule::operator!=
virtual bool operator!=(const TimeZoneRule &that) const override
Return true if the given TimeZoneRule objects are semantically unequal.
icu::InitialTimeZoneRule::getPreviousStart
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const override
Gets the most recent time when this rule takes effect before the specified time.
icu::InitialTimeZoneRule::InitialTimeZoneRule
InitialTimeZoneRule(const InitialTimeZoneRule &source)
Copy constructor.
icu::InitialTimeZoneRule::~InitialTimeZoneRule
virtual ~InitialTimeZoneRule()
Destructor.
icu::InitialTimeZoneRule::getFirstStart
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const override
Gets the very first time when this rule takes effect.
icu::InitialTimeZoneRule::isEquivalentTo
virtual UBool isEquivalentTo(const TimeZoneRule &that) const override
Returns if this rule represents the same rule and offsets as another.
icu::TimeArrayTimeZoneRule::getNextStart
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const override
Gets the first time when this rule takes effect after the specified time.
icu::TimeArrayTimeZoneRule::getFinalStart
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const override
Gets the final time when this rule takes effect.
icu::TimeArrayTimeZoneRule::~TimeArrayTimeZoneRule
virtual ~TimeArrayTimeZoneRule()
Destructor.
icu::TimeArrayTimeZoneRule::TimeArrayTimeZoneRule
TimeArrayTimeZoneRule(const UnicodeString &name, int32_t rawOffset, int32_t dstSavings, const UDate *startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType)
Constructs a TimeArrayTimeZoneRule with the name, the GMT offset of its standard time,...
icu::TimeArrayTimeZoneRule::getFirstStart
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const override
Gets the very first time when this rule takes effect.
icu::TimeArrayTimeZoneRule::isEquivalentTo
virtual UBool isEquivalentTo(const TimeZoneRule &that) const override
Returns if this rule represents the same rule and offsets as another.
icu::TimeArrayTimeZoneRule::getPreviousStart
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const override
Gets the most recent time when this rule takes effect before the specified time.
icu::TimeArrayTimeZoneRule::getStartTimeAt
UBool getStartTimeAt(int32_t index, UDate &result) const
Gets a start time at the index stored in this rule.
icu::TimeArrayTimeZoneRule::operator==
virtual bool operator==(const TimeZoneRule &that) const override
Return true if the given TimeZoneRule objects are semantically equal.
icu::TimeArrayTimeZoneRule::getTimeType
DateTimeRule::TimeRuleType getTimeType() const
Gets the time type of the start times used by this rule.
icu::TimeArrayTimeZoneRule::getDynamicClassID
virtual UClassID getDynamicClassID() const override
Returns a unique class ID POLYMORPHICALLY.
icu::TimeArrayTimeZoneRule::countStartTimes
int32_t countStartTimes() const
Returns the number of start times stored in this rule.
icu::TimeArrayTimeZoneRule::operator=
TimeArrayTimeZoneRule & operator=(const TimeArrayTimeZoneRule &right)
Assignment operator.
icu::TimeArrayTimeZoneRule::TimeArrayTimeZoneRule
TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule &source)
Copy constructor.
icu::TimeArrayTimeZoneRule::getStaticClassID
static UClassID getStaticClassID()
Return the class ID for this class.
icu::TimeArrayTimeZoneRule::operator!=
virtual bool operator!=(const TimeZoneRule &that) const override
Return true if the given TimeZoneRule objects are semantically unequal.
icu::TimeArrayTimeZoneRule::clone
virtual TimeArrayTimeZoneRule * clone() const override
Clone this TimeArrayTimeZoneRule object polymorphically.
icu::TimeZoneRule::getFirstStart
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const =0
Gets the very first time when this rule takes effect.
icu::TimeZoneRule::getRawOffset
int32_t getRawOffset() const
Gets the standard time offset.
icu::TimeZoneRule::TimeZoneRule
TimeZoneRule(const UnicodeString &name, int32_t rawOffset, int32_t dstSavings)
Constructs a TimeZoneRule with the name, the GMT offset of its standard time and the amount of daylig...
icu::TimeZoneRule::getNextStart
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const =0
Gets the first time when this rule takes effect after the specified time.
icu::TimeZoneRule::operator!=
virtual bool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
icu::TimeZoneRule::~TimeZoneRule
virtual ~TimeZoneRule()
Destructor.
icu::TimeZoneRule::isEquivalentTo
virtual UBool isEquivalentTo(const TimeZoneRule &other) const
Returns if this rule represents the same rule and offsets as another.
icu::TimeZoneRule::getPreviousStart
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const =0
Gets the most recent time when this rule takes effect before the specified time.
icu::TimeZoneRule::operator==
virtual bool operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.
icu::TimeZoneRule::operator=
TimeZoneRule & operator=(const TimeZoneRule &right)
Assignment operator.
icu::TimeZoneRule::getFinalStart
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const =0
Gets the final time when this rule takes effect.
icu::TimeZoneRule::TimeZoneRule
TimeZoneRule(const TimeZoneRule &source)
Copy constructor.
icu::TimeZoneRule::getName
UnicodeString & getName(UnicodeString &name) const
Fills in "name" with the name of this time zone.
icu::TimeZoneRule::clone
virtual TimeZoneRule * clone() const =0
Clone this TimeZoneRule object polymorphically.
icu::TimeZoneRule::getDSTSavings
int32_t getDSTSavings() const
Gets the amount of daylight saving delta time from the standard time.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
dtrule.h
C++ API: Rule for specifying date and time in an year.
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
unistr.h
C++ API: Unicode String.
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:316
UDate
double UDate
Date and Time data type.
Definition utypes.h:218