ICU 50.1.2  50.1.2
tzrule.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2007-2008, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
6 */
7 #ifndef TZRULE_H
8 #define TZRULE_H
9 
15 #include "unicode/utypes.h"
16 
17 #if !UCONFIG_NO_FORMATTING
18 
19 #include "unicode/uobject.h"
20 #include "unicode/unistr.h"
21 #include "unicode/dtrule.h"
22 
24 
33 public:
38  virtual ~TimeZoneRule();
39 
46  virtual TimeZoneRule* clone(void) const = 0;
47 
55  virtual UBool operator==(const TimeZoneRule& that) const;
56 
64  virtual UBool operator!=(const TimeZoneRule& that) const;
65 
72  UnicodeString& getName(UnicodeString& name) const;
73 
79  int32_t getRawOffset(void) const;
80 
87  int32_t getDSTSavings(void) const;
88 
97  virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
98 
110  virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
111 
123  virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
124 
139  virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
140  UBool inclusive, UDate& result) const = 0;
141 
156  virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
157  UBool inclusive, UDate& result) const = 0;
158 
159 protected:
160 
170  TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
171 
177  TimeZoneRule(const TimeZoneRule& source);
178 
184  TimeZoneRule& operator=(const TimeZoneRule& right);
185 
186 private:
187  UnicodeString fName; // time name
188  int32_t fRawOffset; // UTC offset of the standard time in milliseconds
189  int32_t fDSTSavings; // DST saving amount in milliseconds
190 };
191 
199 public:
209  InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
210 
217 
222  virtual ~InitialTimeZoneRule();
223 
230  virtual InitialTimeZoneRule* clone(void) const;
231 
238 
246  virtual UBool operator==(const TimeZoneRule& that) const;
247 
255  virtual UBool operator!=(const TimeZoneRule& that) const;
256 
269  UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
270 
279  virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
280 
292  virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
293 
305  virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
306 
321  virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
322  UBool inclusive, UDate& result) const;
323 
338  virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
339  UBool inclusive, UDate& result) const;
340 
341 public:
353  static UClassID U_EXPORT2 getStaticClassID(void);
354 
366  virtual UClassID getDynamicClassID(void) const;
367 };
368 
377 public:
382  static const int32_t MAX_YEAR;
383 
400  AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
401  const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
402 
419  AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
420  DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
421 
427  AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
428 
433  virtual ~AnnualTimeZoneRule();
434 
441  virtual AnnualTimeZoneRule* clone(void) const;
442 
449 
457  virtual UBool operator==(const TimeZoneRule& that) const;
458 
466  virtual UBool operator!=(const TimeZoneRule& that) const;
467 
474  const DateTimeRule* getRule(void) const;
475 
482  int32_t getStartYear(void) const;
483 
490  int32_t getEndYear(void) const;
491 
504  UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
505 
514  virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
515 
527  virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
528 
540  virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
541 
556  virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
557  UBool inclusive, UDate& result) const;
558 
573  virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
574  UBool inclusive, UDate& result) const;
575 
576 
577 private:
578  DateTimeRule* fDateTimeRule;
579  int32_t fStartYear;
580  int32_t fEndYear;
581 
582 public:
594  static UClassID U_EXPORT2 getStaticClassID(void);
595 
607  virtual UClassID getDynamicClassID(void) const;
608 };
609 
617 public:
635  TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
636  const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
637 
644 
649  virtual ~TimeArrayTimeZoneRule();
650 
657  virtual TimeArrayTimeZoneRule* clone(void) const;
658 
665 
673  virtual UBool operator==(const TimeZoneRule& that) const;
674 
682  virtual UBool operator!=(const TimeZoneRule& that) const;
683 
692  DateTimeRule::TimeRuleType getTimeType(void) const;
693 
703  UBool getStartTimeAt(int32_t index, UDate& result) const;
704 
710  int32_t countStartTimes(void) const;
711 
720  virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
721 
733  virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
734 
746  virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
747 
762  virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
763  UBool inclusive, UDate& result) const;
764 
779  virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
780  UBool inclusive, UDate& result) const;
781 
782 
783 private:
784  enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
785  UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
786  UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
787 
788  DateTimeRule::TimeRuleType fTimeRuleType;
789  int32_t fNumStartTimes;
790  UDate* fStartTimes;
791  UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
792 
793 public:
805  static UClassID U_EXPORT2 getStaticClassID(void);
806 
818  virtual UClassID getDynamicClassID(void) const;
819 };
820 
821 
823 
824 #endif /* #if !UCONFIG_NO_FORMATTING */
825 
826 #endif // TZRULE_H
827 
828 //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:51
C++ API: Rule for specifying date and time in an year.
double UDate
Date and Time data type.
Definition: utypes.h:201
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
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:96
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const =0
Gets the final time when this rule takes effect.
virtual UBool isEquivalentTo(const TimeZoneRule &other) const
Returns if this rule represents the same rule and offsets as another.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
TimeZoneRule is a class representing a rule for time zone.
Definition: tzrule.h:32
InitialTimeZoneRule represents a time zone rule representing a time zone effective from the beginning...
Definition: tzrule.h:198
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
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:382
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
TimeArrayTimeZoneRule represents a time zone rule whose start times are defined by an array of millis...
Definition: tzrule.h:616
AnnualTimeZoneRule is a class used for representing a time zone rule which takes effect annually...
Definition: tzrule.h:376
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:130
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:29
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
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 UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
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:246
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:229
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200