ICU 68.2: tzrule.h Source File

ICU 68.2 68.2

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 U_SHOW_CPLUSPLUS_API
20
21 #if !UCONFIG_NO_FORMATTING
22
23 #include "unicode/uobject.h"
24 #include "unicode/unistr.h"
25 #include "unicode/dtrule.h"
26
27 U_NAMESPACE_BEGIN
28
36 class U_I18N_API TimeZoneRule : public UObject {
37 public:
42 virtual ~TimeZoneRule();
43
50 virtual TimeZoneRule* clone() const = 0;
51
59 virtual UBool operator==(const TimeZoneRule& that) const;
60
68 virtual UBool operator!=(const TimeZoneRule& that) const;
69
76 UnicodeString& getName(UnicodeString& name) const;
77
83 int32_t getRawOffset(void) const;
84
91 int32_t getDSTSavings(void) const;
92
101 virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
102
114 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
115
127 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
128
143 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
144 UBool inclusive, UDate& result) const = 0;
145
160 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
161 UBool inclusive, UDate& result) const = 0;
162
163 protected:
164
174 TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
175
181 TimeZoneRule(const TimeZoneRule& source);
182
188 TimeZoneRule& operator=(const TimeZoneRule& right);
189
190 private:
191 UnicodeString fName; // time name
192 int32_t fRawOffset; // UTC offset of the standard time in milliseconds
193 int32_t fDSTSavings; // DST saving amount in milliseconds
194 };
195
202 class U_I18N_API InitialTimeZoneRule : public TimeZoneRule {
203 public:
213 InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
214
220 InitialTimeZoneRule(const InitialTimeZoneRule& source);
221
226 virtual ~InitialTimeZoneRule();
227
234 virtual InitialTimeZoneRule* clone() const;
235
241 InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);
242
250 virtual UBool operator==(const TimeZoneRule& that) const;
251
259 virtual UBool operator!=(const TimeZoneRule& that) const;
260
273 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
274
283 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
284
296 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
297
309 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
310
325 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
326 UBool inclusive, UDate& result) const;
327
342 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
343 UBool inclusive, UDate& result) const;
344
345 public:
357 static UClassID U_EXPORT2 getStaticClassID(void);
358
370 virtual UClassID getDynamicClassID(void) const;
371 };
372
380 class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {
381 public:
386 static const int32_t MAX_YEAR;
387
404 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
405 const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
406
423 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
424 DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
425
431 AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
432
437 virtual ~AnnualTimeZoneRule();
438
445 virtual AnnualTimeZoneRule* clone() const;
446
452 AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);
453
461 virtual UBool operator==(const TimeZoneRule& that) const;
462
470 virtual UBool operator!=(const TimeZoneRule& that) const;
471
478 const DateTimeRule* getRule(void) const;
479
486 int32_t getStartYear(void) const;
487
494 int32_t getEndYear(void) const;
495
508 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
509
518 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
519
531 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
532
544 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
545
560 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
561 UBool inclusive, UDate& result) const;
562
577 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
578 UBool inclusive, UDate& result) const;
579
580
581 private:
582 DateTimeRule* fDateTimeRule;
583 int32_t fStartYear;
584 int32_t fEndYear;
585
586 public:
598 static UClassID U_EXPORT2 getStaticClassID(void);
599
611 virtual UClassID getDynamicClassID(void) const;
612 };
613
620 class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {
621 public:
639 TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
640 const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
641
647 TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);
648
653 virtual ~TimeArrayTimeZoneRule();
654
661 virtual TimeArrayTimeZoneRule* clone() const;
662
668 TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);
669
677 virtual UBool operator==(const TimeZoneRule& that) const;
678
686 virtual UBool operator!=(const TimeZoneRule& that) const;
687
696 DateTimeRule::TimeRuleType getTimeType(void) const;
697
707 UBool getStartTimeAt(int32_t index, UDate& result) const;
708
714 int32_t countStartTimes(void) const;
715
724 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
725
737 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
738
750 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
751
766 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
767 UBool inclusive, UDate& result) const;
768
783 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
784 UBool inclusive, UDate& result) const;
785
786
787 private:
788 enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
789 UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
790 UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
791
792 DateTimeRule::TimeRuleType fTimeRuleType;
793 int32_t fNumStartTimes;
794 UDate* fStartTimes;
795 UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
796
797 public:
809 static UClassID U_EXPORT2 getStaticClassID(void);
810
822 virtual UClassID getDynamicClassID(void) const;
823 };
824
825
826 U_NAMESPACE_END
827
828 #endif /* #if !UCONFIG_NO_FORMATTING */
829
830 #endif /* U_SHOW_CPLUSPLUS_API */
831
832 #endif // TZRULE_H
833
834 //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::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:620
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:386
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
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
TimeZoneRule is a class representing a rule for time zone.
Definition: tzrule.h:36
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() 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:295
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:380
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:223
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:96
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::InitialTimeZoneRule::getStaticClassID
static UClassID getStaticClassID(void)
Return the class ID for this class.
icu::TimeArrayTimeZoneRule::clone
virtual TimeArrayTimeZoneRule * clone() const
Clone this TimeArrayTimeZoneRule object polymorphically.
icu::DateTimeRule::TimeRuleType
TimeRuleType
Time rule type constants.
Definition: dtrule.h:55
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:202
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.
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.
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:33
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::InitialTimeZoneRule::clone
virtual InitialTimeZoneRule * clone() const
Clone this InitialTimeZoneRule object polymorphically.
icu::TimeZoneRule::clone
virtual TimeZoneRule * clone() const =0
Clone this TimeZoneRule 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.