1 /*
2  ********************************************************************************
3  * Copyright (C) 2003-2013, 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 
176 U_NAMESPACE_END
177 
178 #endif /* #if !UCONFIG_NO_FORMATTING */
179 
180 #endif // _TAIWNCAL
181 //eof
182 
183