]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/taiwncal.h
ICU-461.12.tar.gz
[apple/icu.git] / icuSources / i18n / taiwncal.h
1 /*
2 ********************************************************************************
3 * Copyright (C) 2003-2007, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 ********************************************************************************
6 *
7 * File BUDDHCAL.H
8 *
9 * Modification History:
10 *
11 * Date Name Description
12 * 05/13/2003 srl copied from gregocal.h
13 * 06/29/2007 srl copied from buddhcal.h
14 ********************************************************************************
15 */
16
17 #ifndef TAIWNCAL_H
18 #define TAIWNCAL_H
19
20 #include "unicode/utypes.h"
21
22 #if !UCONFIG_NO_FORMATTING
23
24 #include "unicode/calendar.h"
25 #include "unicode/gregocal.h"
26
27 U_NAMESPACE_BEGIN
28
29 /**
30 * Concrete class which provides the Taiwan calendar.
31 * <P>
32 * <code>TaiwanCalendar</code> is a subclass of <code>GregorianCalendar</code>
33 * that numbers years since 1912
34 * <p>
35 * The Taiwan calendar is identical to the Gregorian calendar in all respects
36 * except for the year and era. Years are numbered since 1912 AD (Gregorian),
37 * so that 1912 AD (Gregorian) is equivalent to 1 MINGUO (Minguo Era) and 1998 AD is 87 MINGUO.
38 * <p>
39 * The Taiwan Calendar has two eras: <code>BEFORE_MINGUO</code> and <code>MINGUO</code>.
40 * <p>
41 * @internal
42 */
43 class TaiwanCalendar : public GregorianCalendar {
44 public:
45
46 /**
47 * Useful constants for TaiwanCalendar. Only one Era.
48 * @internal
49 */
50 enum EEras {
51 BEFORE_MINGUO = 0,
52 MINGUO = 1
53 };
54
55 /**
56 * Constructs a TaiwanCalendar based on the current time in the default time zone
57 * with the given locale.
58 *
59 * @param aLocale The given locale.
60 * @param success Indicates the status of TaiwanCalendar object construction.
61 * Returns U_ZERO_ERROR if constructed successfully.
62 * @internal
63 */
64 TaiwanCalendar(const Locale& aLocale, UErrorCode& success);
65
66
67 /**
68 * Destructor
69 * @internal
70 */
71 virtual ~TaiwanCalendar();
72
73 /**
74 * Copy constructor
75 * @param source the object to be copied.
76 * @internal
77 */
78 TaiwanCalendar(const TaiwanCalendar& source);
79
80 /**
81 * Default assignment operator
82 * @param right the object to be copied.
83 * @internal
84 */
85 TaiwanCalendar& operator=(const TaiwanCalendar& right);
86
87 /**
88 * Create and return a polymorphic copy of this calendar.
89 * @return return a polymorphic copy of this calendar.
90 * @internal
91 */
92 virtual Calendar* clone(void) const;
93
94 public:
95 /**
96 * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
97 * override. This method is to implement a simple version of RTTI, since not all C++
98 * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
99 * this method.
100 *
101 * @return The class ID for this object. All objects of a given class have the
102 * same class ID. Objects of other classes have different class IDs.
103 * @internal
104 */
105 virtual UClassID getDynamicClassID(void) const;
106
107 /**
108 * Return the class ID for this class. This is useful only for comparing to a return
109 * value from getDynamicClassID(). For example:
110 *
111 * Base* polymorphic_pointer = createPolymorphicObject();
112 * if (polymorphic_pointer->getDynamicClassID() ==
113 * Derived::getStaticClassID()) ...
114 *
115 * @return The class ID for all objects of this class.
116 * @internal
117 */
118 U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
119
120 /**
121 * return the calendar type, "Taiwan".
122 *
123 * @return calendar type
124 * @internal
125 */
126 virtual const char * getType() const;
127
128 private:
129 TaiwanCalendar(); // default constructor not implemented
130
131 protected:
132 /**
133 * Return the extended year defined by the current fields. This will
134 * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
135 * as UCAL_ERA) specific to the calendar system, depending on which set of
136 * fields is newer.
137 * @return the extended year
138 * @internal
139 */
140 virtual int32_t handleGetExtendedYear();
141 /**
142 * Subclasses may override this method to compute several fields
143 * specific to each calendar system.
144 * @internal
145 */
146 virtual void handleComputeFields(int32_t julianDay, UErrorCode& status);
147 /**
148 * Subclass API for defining limits of different types.
149 * @param field one of the field numbers
150 * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
151 * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
152 * @internal
153 */
154 virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
155
156 /**
157 * Returns TRUE because the Taiwan Calendar does have a default century
158 * @internal
159 */
160 virtual UBool haveDefaultCentury() const;
161
162 /**
163 * Returns the date of the start of the default century
164 * @return start of century - in milliseconds since epoch, 1970
165 * @internal
166 */
167 virtual UDate defaultCenturyStart() const;
168
169 /**
170 * Returns the year in which the default century begins
171 * @internal
172 */
173 virtual int32_t defaultCenturyStartYear() const;
174
175 private: // default century stuff.
176 /**
177 * The system maintains a static default century start date. This is initialized
178 * the first time it is used. Before then, it is set to SYSTEM_DEFAULT_CENTURY to
179 * indicate an uninitialized state. Once the system default century date and year
180 * are set, they do not change.
181 */
182 static UDate fgSystemDefaultCenturyStart;
183
184 /**
185 * See documentation for systemDefaultCenturyStart.
186 */
187 static int32_t fgSystemDefaultCenturyStartYear;
188
189 /**
190 * Default value that indicates the defaultCenturyStartYear is unitialized
191 */
192 static const int32_t fgSystemDefaultCenturyYear;
193
194 /**
195 * start of default century, as a date
196 */
197 static const UDate fgSystemDefaultCentury;
198
199 /**
200 * Returns the beginning date of the 100-year window that dates
201 * with 2-digit years are considered to fall within.
202 */
203 UDate internalGetDefaultCenturyStart(void) const;
204
205 /**
206 * Returns the first year of the 100-year window that dates with
207 * 2-digit years are considered to fall within.
208 */
209 int32_t internalGetDefaultCenturyStartYear(void) const;
210
211 /**
212 * Initializes the 100-year window that dates with 2-digit years
213 * are considered to fall within so that its start date is 80 years
214 * before the current time.
215 */
216 static void initializeSystemDefaultCentury(void);
217 };
218
219 U_NAMESPACE_END
220
221 #endif /* #if !UCONFIG_NO_FORMATTING */
222
223 #endif // _TAIWNCAL
224 //eof
225