ICU 62.1 62.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
35public:
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
159 UBool inclusive, UDate& result) const = 0;
160
161protected:
162
172 TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
173
180
187
188private:
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
201public:
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
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
341 UBool inclusive, UDate& result) const;
342
343public:
356
368 virtual UClassID getDynamicClassID(void) const;
369};
370
379public:
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
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
576 UBool inclusive, UDate& result) const;
577
578
579private:
580 DateTimeRule* fDateTimeRule;
581 int32_t fStartYear;
582 int32_t fEndYear;
583
584public:
597
609 virtual UClassID getDynamicClassID(void) const;
610};
611
619public:
637 TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
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
782 UBool inclusive, UDate& result) const;
783
784
785private:
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
795public:
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
AnnualTimeZoneRule is a class used for representing a time zone rule which takes effect annually.
Definition tzrule.h:378
virtual UBool operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.
virtual ~AnnualTimeZoneRule()
Destructor.
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
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,...
static const int32_t MAX_YEAR
The constant representing the maximum year used for designating a rule is permanent.
Definition tzrule.h:384
AnnualTimeZoneRule & operator=(const AnnualTimeZoneRule &right)
Assignment operator.
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
virtual UBool isEquivalentTo(const TimeZoneRule &that) const
Returns if this rule represents the same rule and offsets as another.
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.
const DateTimeRule * getRule(void) const
Gets the start date/time rule used by this rule.
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,...
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the very first time when this rule takes effect.
int32_t getEndYear(void) const
Gets the end year when this rule takes effect.
int32_t getStartYear(void) const
Gets the first year when this rule takes effect.
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.
static UClassID getStaticClassID(void)
Return the class ID for this class.
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the final time when this rule takes effect.
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 AnnualTimeZoneRule * clone(void) const
Clone this AnnualTimeZoneRule object polymorphically.
AnnualTimeZoneRule(const AnnualTimeZoneRule &source)
Copy constructor.
DateTimeRule is a class representing a time in a year by a rule specified by month,...
Definition dtrule.h:31
TimeRuleType
Time rule type constants.
Definition dtrule.h:53
InitialTimeZoneRule represents a time zone rule representing a time zone effective from the beginning...
Definition tzrule.h:200
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...
static UClassID getStaticClassID(void)
Return the class ID for this class.
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.
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 operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
virtual UBool isEquivalentTo(const TimeZoneRule &that) const
Returns if this rule represents the same rule and offsets as another.
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the final time when this rule takes effect.
InitialTimeZoneRule & operator=(const InitialTimeZoneRule &right)
Assignment operator.
InitialTimeZoneRule(const InitialTimeZoneRule &source)
Copy constructor.
virtual InitialTimeZoneRule * clone(void) const
Clone this InitialTimeZoneRule object polymorphically.
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the very first time when this rule takes effect.
virtual ~InitialTimeZoneRule()
Destructor.
virtual UBool operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.
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 UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
"Smart pointer" base class; do not use directly: use LocalPointer etc.
TimeArrayTimeZoneRule represents a time zone rule whose start times are defined by an array of millis...
Definition tzrule.h:618
virtual ~TimeArrayTimeZoneRule()
Destructor.
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 equal.
DateTimeRule::TimeRuleType getTimeType(void) const
Gets the time type of the start times used by this rule.
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 UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the final time when this rule takes effect.
UBool getStartTimeAt(int32_t index, UDate &result) const
Gets a start time at the index stored in this rule.
virtual UBool isEquivalentTo(const TimeZoneRule &that) const
Returns if this rule represents the same rule and offsets as another.
static UClassID getStaticClassID(void)
Return the class ID for this class.
virtual TimeArrayTimeZoneRule * clone(void) const
Clone this TimeArrayTimeZoneRule object polymorphically.
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const
Gets the very first time when this rule takes effect.
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
TimeArrayTimeZoneRule & operator=(const TimeArrayTimeZoneRule &right)
Assignment operator.
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(const TimeArrayTimeZoneRule &source)
Copy constructor.
int32_t countStartTimes(void) const
Returns the number of start times stored in this rule.
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
TimeZoneRule is a class representing a rule for time zone.
Definition tzrule.h:34
virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const =0
Gets the very first 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...
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 operator==(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically equal.
int32_t getRawOffset(void) const
Gets the standard time offset.
virtual ~TimeZoneRule()
Destructor.
virtual UBool isEquivalentTo(const TimeZoneRule &other) const
Returns if this rule represents the same rule and offsets as another.
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.
int32_t getDSTSavings(void) const
Gets the amount of daylight saving delta time from the standard time.
TimeZoneRule & operator=(const TimeZoneRule &right)
Assignment operator.
virtual TimeZoneRule * clone(void) const =0
Clone this TimeZoneRule object polymorphically.
virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate &result) const =0
Gets the final time when this rule takes effect.
TimeZoneRule(const TimeZoneRule &source)
Copy constructor.
UnicodeString & getName(UnicodeString &name) const
Fills in "name" with the name of this time zone.
virtual UBool operator!=(const TimeZoneRule &that) const
Return true if the given TimeZoneRule objects are semantically unequal.
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:287
C++ API: Rule for specifying date and time in an year.
int8_t UBool
The ICU boolean type.
Definition umachine.h:236
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:93
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:396
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:360
double UDate
Date and Time data type.
Definition utypes.h:203
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:138
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:137