ICU 57.1 57.1
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
33public:
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
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
159protected:
160
170 TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
171
178
185
186private:
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
199public:
209 InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
210
217
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
341public:
353 static UClassID U_EXPORT2 getStaticClassID(void);
354
366 virtual UClassID getDynamicClassID(void) const;
367};
368
377public:
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
428
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
577private:
578 DateTimeRule* fDateTimeRule;
579 int32_t fStartYear;
580 int32_t fEndYear;
581
582public:
594 static UClassID U_EXPORT2 getStaticClassID(void);
595
607 virtual UClassID getDynamicClassID(void) const;
608};
609
617public:
635 TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
636 const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
637
644
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
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
783private:
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
793public:
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
AnnualTimeZoneRule is a class used for representing a time zone rule which takes effect annually.
Definition: tzrule.h:376
static UClassID getStaticClassID(void)
Return the class ID for this class.
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,...
int32_t getEndYear(void) const
Gets the end year when this rule takes effect.
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
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 equal.
int32_t getStartYear(void) const
Gets the first year when this rule takes effect.
AnnualTimeZoneRule(const AnnualTimeZoneRule &source)
Copy constructor.
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.
virtual ~AnnualTimeZoneRule()
Destructor.
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,...
AnnualTimeZoneRule & operator=(const AnnualTimeZoneRule &right)
Assignment operator.
const DateTimeRule * getRule(void) const
Gets the start date/time rule used by this rule.
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.
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
virtual AnnualTimeZoneRule * clone(void) const
Clone this AnnualTimeZoneRule object polymorphically.
static const int32_t MAX_YEAR
The constant representing the maximum year used for designating a rule is permanent.
Definition: tzrule.h:382
virtual UBool isEquivalentTo(const TimeZoneRule &that) const
Returns if this rule represents the same rule and offsets as another.
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.
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the very first time when this rule takes effect.
DateTimeRule is a class representing a time in a year by a rule specified by month,...
Definition: dtrule.h:29
TimeRuleType
Time rule type constants.
Definition: dtrule.h:51
InitialTimeZoneRule represents a time zone rule representing a time zone effective from the beginning...
Definition: tzrule.h:198
static UClassID getStaticClassID(void)
Return the class ID for this class.
virtual UBool isEquivalentTo(const TimeZoneRule &that) const
Returns if this rule represents the same rule and offsets as another.
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the very first time when this rule takes effect.
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
virtual ~InitialTimeZoneRule()
Destructor.
InitialTimeZoneRule & operator=(const InitialTimeZoneRule &right)
Assignment operator.
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
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 equal.
virtual InitialTimeZoneRule * clone(void) const
Clone this InitialTimeZoneRule object polymorphically.
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
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.
InitialTimeZoneRule(const InitialTimeZoneRule &source)
Copy constructor.
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...
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.
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.
TimeArrayTimeZoneRule represents a time zone rule whose start times are defined by an array of millis...
Definition: tzrule.h:616
DateTimeRule::TimeRuleType getTimeType(void) const
Gets the time type of the start times used by this rule.
virtual ~TimeArrayTimeZoneRule()
Destructor.
UBool getStartTimeAt(int32_t index, UDate &result) const
Gets a start time at the index stored in this rule.
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.
virtual UBool operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.
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,...
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
TimeArrayTimeZoneRule & operator=(const TimeArrayTimeZoneRule &right)
Assignment operator.
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
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.
int32_t countStartTimes(void) const
Returns the number of start times stored in this rule.
virtual UBool isEquivalentTo(const TimeZoneRule &that) const
Returns if this rule represents the same rule and offsets as another.
virtual TimeArrayTimeZoneRule * clone(void) const
Clone this TimeArrayTimeZoneRule object polymorphically.
TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule &source)
Copy constructor.
static UClassID getStaticClassID(void)
Return the class ID for this class.
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.
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the very first time when this rule takes effect.
TimeZoneRule is a class representing a rule for time zone.
Definition: tzrule.h:32
virtual ~TimeZoneRule()
Destructor.
virtual UBool operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.
TimeZoneRule(const TimeZoneRule &source)
Copy constructor.
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const =0
Gets the very first time when this rule takes effect.
int32_t getRawOffset(void) const
Gets the standard time offset.
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
int32_t getDSTSavings(void) const
Gets the amount of daylight saving delta time from the standard time.
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.
TimeZoneRule & operator=(const TimeZoneRule &right)
Assignment operator.
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const =0
Gets the final time when this rule takes effect.
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...
UnicodeString & getName(UnicodeString &name) const
Fills in "name" with the name of this time zone.
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.
virtual UBool isEquivalentTo(const TimeZoneRule &other) const
Returns if this rule represents the same rule and offsets as another.
virtual TimeZoneRule * clone(void) const =0
Clone this TimeZoneRule object polymorphically.
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
C++ API: Rule for specifying date and time in an year.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
C++ API: Unicode String.
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:358
double UDate
Date and Time data type.
Definition: utypes.h:201
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129