ICU 63.1  63.1
tzrule.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 * Copyright (C) 2007-2008, International Business Machines Corporation and *
6 * others. All Rights Reserved. *
7 *******************************************************************************
8 */
9 #ifndef TZRULE_H
10 #define TZRULE_H
11 
17 #include "unicode/utypes.h"
18 
19 #if !UCONFIG_NO_FORMATTING
20 
21 #include "unicode/uobject.h"
22 #include "unicode/unistr.h"
23 #include "unicode/dtrule.h"
24 
26 
35 public:
40  virtual ~TimeZoneRule();
41 
48  virtual TimeZoneRule* clone(void) const = 0;
49 
57  virtual UBool operator==(const TimeZoneRule& that) const;
58 
66  virtual UBool operator!=(const TimeZoneRule& that) const;
67 
75 
81  int32_t getRawOffset(void) const;
82 
89  int32_t getDSTSavings(void) const;
90 
99  virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
100 
112  virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
113 
125  virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
126 
141  virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
142  UBool inclusive, UDate& result) const = 0;
143 
158  virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
159  UBool inclusive, UDate& result) const = 0;
160 
161 protected:
162 
172  TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
173 
179  TimeZoneRule(const TimeZoneRule& source);
180 
187 
188 private:
189  UnicodeString fName; // time name
190  int32_t fRawOffset; // UTC offset of the standard time in milliseconds
191  int32_t fDSTSavings; // DST saving amount in milliseconds
192 };
193 
201 public:
211  InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
212 
219 
225 
232  virtual InitialTimeZoneRule* clone(void) const;
233 
240 
248  virtual UBool operator==(const TimeZoneRule& that) const;
249 
257  virtual UBool operator!=(const TimeZoneRule& that) const;
258 
271  UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
272 
281  virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
282 
294  virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
295 
307  virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
308 
323  virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
324  UBool inclusive, UDate& result) const;
325 
340  virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
341  UBool inclusive, UDate& result) const;
342 
343 public:
355  static UClassID U_EXPORT2 getStaticClassID(void);
356 
368  virtual UClassID getDynamicClassID(void) const;
369 };
370 
379 public:
384  static const int32_t MAX_YEAR;
385 
402  AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
403  const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
404 
421  AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
422  DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
423 
430 
436 
443  virtual AnnualTimeZoneRule* clone(void) const;
444 
451 
459  virtual UBool operator==(const TimeZoneRule& that) const;
460 
468  virtual UBool operator!=(const TimeZoneRule& that) const;
469 
476  const DateTimeRule* getRule(void) const;
477 
484  int32_t getStartYear(void) const;
485 
492  int32_t getEndYear(void) const;
493 
506  UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
507 
516  virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
517 
529  virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
530 
542  virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
543 
558  virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
559  UBool inclusive, UDate& result) const;
560 
575  virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
576  UBool inclusive, UDate& result) const;
577 
578 
579 private:
580  DateTimeRule* fDateTimeRule;
581  int32_t fStartYear;
582  int32_t fEndYear;
583 
584 public:
596  static UClassID U_EXPORT2 getStaticClassID(void);
597 
609  virtual UClassID getDynamicClassID(void) const;
610 };
611 
619 public:
637  TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
638  const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
639 
646 
652 
659  virtual TimeArrayTimeZoneRule* clone(void) const;
660 
667 
675  virtual UBool operator==(const TimeZoneRule& that) const;
676 
684  virtual UBool operator!=(const TimeZoneRule& that) const;
685 
695 
705  UBool getStartTimeAt(int32_t index, UDate& result) const;
706 
712  int32_t countStartTimes(void) const;
713 
722  virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
723 
735  virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
736 
748  virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
749 
764  virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
765  UBool inclusive, UDate& result) const;
766 
781  virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
782  UBool inclusive, UDate& result) const;
783 
784 
785 private:
786  enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
787  UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
788  UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
789 
790  DateTimeRule::TimeRuleType fTimeRuleType;
791  int32_t fNumStartTimes;
792  UDate* fStartTimes;
793  UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
794 
795 public:
807  static UClassID U_EXPORT2 getStaticClassID(void);
808 
820  virtual UClassID getDynamicClassID(void) const;
821 };
822 
823 
825 
826 #endif /* #if !UCONFIG_NO_FORMATTING */
827 
828 #endif // TZRULE_H
829 
830 //eof
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::InitialTimeZoneRule::operator=
InitialTimeZoneRule & operator=(const InitialTimeZoneRule &right)
Assignment operator.
icu::TimeArrayTimeZoneRule::~TimeArrayTimeZoneRule
virtual ~TimeArrayTimeZoneRule()
Destructor.
icu::InitialTimeZoneRule::clone
virtual InitialTimeZoneRule * clone(void) const
Clone this InitialTimeZoneRule object polymorphically.
icu::TimeZoneRule::isEquivalentTo
virtual UBool isEquivalentTo(const TimeZoneRule &other) const
Returns if this rule represents the same rule and offsets as another.
icu::TimeZoneRule::getRawOffset
int32_t getRawOffset(void) const
Gets the standard time offset.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::TimeArrayTimeZoneRule
TimeArrayTimeZoneRule represents a time zone rule whose start times are defined by an array of millis...
Definition: tzrule.h:618
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:301
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:384
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225
icu::InitialTimeZoneRule::getNextStart
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const
Gets the first time when this rule takes effect after the specified time.
icu::TimeArrayTimeZoneRule::TimeArrayTimeZoneRule
TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule &source)
Copy constructor.
icu::TimeZoneRule::~TimeZoneRule
virtual ~TimeZoneRule()
Destructor.
icu::AnnualTimeZoneRule::getRule
const DateTimeRule * getRule(void) const
Gets the start date/time rule used by this rule.
icu::TimeZoneRule::clone
virtual TimeZoneRule * clone(void) const =0
Clone this TimeZoneRule object polymorphically.
icu::TimeZoneRule
TimeZoneRule is a class representing a rule for time zone.
Definition: tzrule.h:34
icu::AnnualTimeZoneRule::AnnualTimeZoneRule
AnnualTimeZoneRule(const AnnualTimeZoneRule &source)
Copy constructor.
icu::InitialTimeZoneRule::operator!=
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
icu::AnnualTimeZoneRule::~AnnualTimeZoneRule
virtual ~AnnualTimeZoneRule()
Destructor.
dtrule.h
C++ API: Rule for specifying date and time in an year.
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::AnnualTimeZoneRule::clone
virtual AnnualTimeZoneRule * clone(void) const
Clone this AnnualTimeZoneRule object polymorphically.
icu::TimeArrayTimeZoneRule::getPreviousStart
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const
Gets the most recent time when this rule takes effect before the specified time.
icu::InitialTimeZoneRule::~InitialTimeZoneRule
virtual ~InitialTimeZoneRule()
Destructor.
icu::TimeArrayTimeZoneRule::getFinalStart
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the final time when this rule takes effect.
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::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:290
icu::TimeZoneRule::operator=
TimeZoneRule & operator=(const TimeZoneRule &right)
Assignment operator.
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::getStartYear
int32_t getStartYear(void) const
Gets the first year when this rule takes effect.
icu::AnnualTimeZoneRule
AnnualTimeZoneRule is a class used for representing a time zone rule which takes effect annually.
Definition: tzrule.h:378
icu::AnnualTimeZoneRule::getPreviousStart
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const
Gets the most recent time when this rule takes effect before the specified time.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:220
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.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:90
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:401
icu::InitialTimeZoneRule::getStaticClassID
static UClassID getStaticClassID(void)
Return the class ID for this class.
icu::DateTimeRule::TimeRuleType
TimeRuleType
Time rule type constants.
Definition: dtrule.h:53
icu::TimeArrayTimeZoneRule::operator==
virtual UBool operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.
icu::TimeArrayTimeZoneRule::getTimeType
DateTimeRule::TimeRuleType getTimeType(void) const
Gets the time type of the start times used by this rule.
icu::InitialTimeZoneRule::InitialTimeZoneRule
InitialTimeZoneRule(const InitialTimeZoneRule &source)
Copy constructor.
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::TimeArrayTimeZoneRule::isEquivalentTo
virtual UBool isEquivalentTo(const TimeZoneRule &that) const
Returns if this rule represents the same rule and offsets as another.
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::getFirstStart
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the very first time when this rule takes effect.
icu::TimeArrayTimeZoneRule::getDynamicClassID
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
icu::TimeArrayTimeZoneRule::operator=
TimeArrayTimeZoneRule & operator=(const TimeArrayTimeZoneRule &right)
Assignment operator.
icu::TimeArrayTimeZoneRule::countStartTimes
int32_t countStartTimes(void) const
Returns the number of start times stored in this rule.
icu::InitialTimeZoneRule
InitialTimeZoneRule represents a time zone rule representing a time zone effective from the beginning...
Definition: tzrule.h:200
icu::AnnualTimeZoneRule::isEquivalentTo
virtual UBool isEquivalentTo(const TimeZoneRule &that) const
Returns if this rule represents the same rule and offsets as another.
icu::InitialTimeZoneRule::operator==
virtual UBool operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.
icu::TimeZoneRule::operator!=
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
icu::AnnualTimeZoneRule::getStaticClassID
static UClassID getStaticClassID(void)
Return the class ID for this class.
icu::AnnualTimeZoneRule::getDynamicClassID
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
icu::InitialTimeZoneRule::getFinalStart
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the final time when this rule takes effect.
icu::TimeZoneRule::getName
UnicodeString & getName(UnicodeString &name) const
Fills in "name" with the name of this time zone.
icu::TimeArrayTimeZoneRule::getNextStart
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const
Gets the first time when this rule takes effect after 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.
UDate
double UDate
Date and Time data type.
Definition: utypes.h:203
icu::InitialTimeZoneRule::isEquivalentTo
virtual UBool isEquivalentTo(const TimeZoneRule &that) const
Returns if this rule represents the same rule and offsets as another.
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::getFinalStart
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the final time when this rule takes effect.
icu::AnnualTimeZoneRule::operator!=
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
icu::TimeZoneRule::getDSTSavings
int32_t getDSTSavings(void) const
Gets the amount of daylight saving delta time from the standard time.
icu::AnnualTimeZoneRule::operator=
AnnualTimeZoneRule & operator=(const AnnualTimeZoneRule &right)
Assignment operator.
icu::InitialTimeZoneRule::getPreviousStart
virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const
Gets the most recent time when this rule takes effect before the specified time.
icu::TimeArrayTimeZoneRule::operator!=
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
icu::TimeArrayTimeZoneRule::getFirstStart
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the very first time when this rule takes effect.
icu::TimeArrayTimeZoneRule::getStaticClassID
static UClassID getStaticClassID(void)
Return the class ID for this class.
icu::TimeZoneRule::TimeZoneRule
TimeZoneRule(const TimeZoneRule &source)
Copy constructor.
icu::InitialTimeZoneRule::getDynamicClassID
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
icu::TimeZoneRule::operator==
virtual UBool operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.
icu::AnnualTimeZoneRule::getEndYear
int32_t getEndYear(void) const
Gets the end year when this rule takes effect.
uobject.h
C++ API: Common ICU base class UObject.
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.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
icu::AnnualTimeZoneRule::getFirstStart
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the very first time when this rule takes effect.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
icu::AnnualTimeZoneRule::getNextStart
virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, UBool inclusive, UDate &result) const
Gets the first time when this rule takes effect after the specified time.
icu::DateTimeRule
DateTimeRule is a class representing a time in a year by a rule specified by month,...
Definition: dtrule.h:31
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.
unistr.h
C++ API: Unicode String.
icu::TimeArrayTimeZoneRule::clone
virtual TimeArrayTimeZoneRule * clone(void) const
Clone this TimeArrayTimeZoneRule object polymorphically.
icu::InitialTimeZoneRule::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::operator==
virtual UBool operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.