ICU 59.1  59.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 
74  UnicodeString& getName(UnicodeString& name) const;
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 
186  TimeZoneRule& operator=(const TimeZoneRule& right);
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 
224  virtual ~InitialTimeZoneRule();
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 
429  AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
430 
435  virtual ~AnnualTimeZoneRule();
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 
651  virtual ~TimeArrayTimeZoneRule();
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 
694  DateTimeRule::TimeRuleType getTimeType(void) const;
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
virtual UBool operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.
TimeRuleType
Time rule type constants.
Definition: dtrule.h:53
C++ API: Rule for specifying date and time in an year.
double UDate
Date and Time data type.
Definition: utypes.h:203
C++ API: Unicode String.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:93
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const =0
Gets the final time when this rule takes effect.
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:360
TimeZoneRule is a class representing a rule for time zone.
Definition: tzrule.h:34
InitialTimeZoneRule represents a time zone rule representing a time zone effective from the beginning...
Definition: tzrule.h:200
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
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.
TimeZoneRule & operator=(const TimeZoneRule &right)
Assignment operator.
static const int32_t MAX_YEAR
The constant representing the maximum year used for designating a rule is permanent.
Definition: tzrule.h:384
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
virtual UBool isEquivalentTo(const TimeZoneRule &other) const
Returns if this rule represents the same rule and offsets as another.
TimeArrayTimeZoneRule represents a time zone rule whose start times are defined by an array of millis...
Definition: tzrule.h:618
AnnualTimeZoneRule is a class used for representing a time zone rule which takes effect annually...
Definition: tzrule.h:378
C++ API: Common ICU base class UObject.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
DateTimeRule is a class representing a time in a year by a rule specified by month, day of month, day of week and time in the day.
Definition: dtrule.h:31
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
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.
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const =0
Gets the very first time when this rule takes effect.
Basic definitions for ICU, for both C and C++ APIs.
virtual TimeZoneRule * clone(void) const =0
Clone this TimeZoneRule object polymorphically.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236