2 ********************************************************************************
3 * Copyright (C) 2003-2007, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 ********************************************************************************
9 * Modification History:
11 * Date Name Description
12 * 05/13/2003 srl copied from gregocal.h
13 * 06/29/2007 srl copied from buddhcal.h
14 ********************************************************************************
20 #include "unicode/utypes.h"
22 #if !UCONFIG_NO_FORMATTING
24 #include "unicode/calendar.h"
25 #include "unicode/gregocal.h"
30 * Concrete class which provides the Taiwan calendar.
32 * <code>TaiwanCalendar</code> is a subclass of <code>GregorianCalendar</code>
33 * that numbers years since 1912
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.
39 * The Taiwan Calendar has two eras: <code>BEFORE_MINGUO</code> and <code>MINGUO</code>.
43 class TaiwanCalendar
: public GregorianCalendar
{
47 * Useful constants for TaiwanCalendar. Only one Era.
56 * Constructs a TaiwanCalendar based on the current time in the default time zone
57 * with the given locale.
59 * @param aLocale The given locale.
60 * @param success Indicates the status of TaiwanCalendar object construction.
61 * Returns U_ZERO_ERROR if constructed successfully.
64 TaiwanCalendar(const Locale
& aLocale
, UErrorCode
& success
);
71 virtual ~TaiwanCalendar();
75 * @param source the object to be copied.
78 TaiwanCalendar(const TaiwanCalendar
& source
);
81 * Default assignment operator
82 * @param right the object to be copied.
85 TaiwanCalendar
& operator=(const TaiwanCalendar
& right
);
88 * Create and return a polymorphic copy of this calendar.
89 * @return return a polymorphic copy of this calendar.
92 virtual Calendar
* clone(void) const;
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
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.
105 virtual UClassID
getDynamicClassID(void) const;
108 * Return the class ID for this class. This is useful only for comparing to a return
109 * value from getDynamicClassID(). For example:
111 * Base* polymorphic_pointer = createPolymorphicObject();
112 * if (polymorphic_pointer->getDynamicClassID() ==
113 * Derived::getStaticClassID()) ...
115 * @return The class ID for all objects of this class.
118 U_I18N_API
static UClassID U_EXPORT2
getStaticClassID(void);
121 * return the calendar type, "Taiwan".
123 * @return calendar type
126 virtual const char * getType() const;
129 TaiwanCalendar(); // default constructor not implemented
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
137 * @return the extended year
140 virtual int32_t handleGetExtendedYear();
142 * Subclasses may override this method to compute several fields
143 * specific to each calendar system.
146 virtual void handleComputeFields(int32_t julianDay
, UErrorCode
& status
);
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>
154 virtual int32_t handleGetLimit(UCalendarDateFields field
, ELimitType limitType
) const;
157 * Returns TRUE because the Taiwan Calendar does have a default century
160 virtual UBool
haveDefaultCentury() const;
163 * Returns the date of the start of the default century
164 * @return start of century - in milliseconds since epoch, 1970
167 virtual UDate
defaultCenturyStart() const;
170 * Returns the year in which the default century begins
173 virtual int32_t defaultCenturyStartYear() const;
175 private: // default century stuff.
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.
182 static UDate fgSystemDefaultCenturyStart
;
185 * See documentation for systemDefaultCenturyStart.
187 static int32_t fgSystemDefaultCenturyStartYear
;
190 * Default value that indicates the defaultCenturyStartYear is unitialized
192 static const int32_t fgSystemDefaultCenturyYear
;
195 * start of default century, as a date
197 static const UDate fgSystemDefaultCentury
;
200 * Returns the beginning date of the 100-year window that dates
201 * with 2-digit years are considered to fall within.
203 UDate
internalGetDefaultCenturyStart(void) const;
206 * Returns the first year of the 100-year window that dates with
207 * 2-digit years are considered to fall within.
209 int32_t internalGetDefaultCenturyStartYear(void) const;
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.
216 static void initializeSystemDefaultCentury(void);
221 #endif /* #if !UCONFIG_NO_FORMATTING */