intl/icu/source/i18n/japancal.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/japancal.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,217 @@
     1.4 +/*
     1.5 + ********************************************************************************
     1.6 + * Copyright (C) 2003-2008, International Business Machines Corporation
     1.7 + * and others. All Rights Reserved.
     1.8 + ********************************************************************************
     1.9 + *
    1.10 + * File JAPANCAL.H
    1.11 + *
    1.12 + * Modification History:
    1.13 + *
    1.14 + *   Date        Name        Description
    1.15 + *   05/13/2003  srl         copied from gregocal.h
    1.16 + ********************************************************************************
    1.17 + */
    1.18 +
    1.19 +#ifndef JAPANCAL_H
    1.20 +#define JAPANCAL_H
    1.21 +
    1.22 +#include "unicode/utypes.h"
    1.23 +
    1.24 +#if !UCONFIG_NO_FORMATTING
    1.25 +
    1.26 +#include "unicode/calendar.h"
    1.27 +#include "unicode/gregocal.h"
    1.28 +
    1.29 +U_NAMESPACE_BEGIN
    1.30 +
    1.31 +/**
    1.32 + * Concrete class which provides the Japanese calendar.
    1.33 + * <P>
    1.34 + * <code>JapaneseCalendar</code> is a subclass of <code>GregorianCalendar</code>
    1.35 + * that numbers years and eras based on the reigns of the Japanese emperors.
    1.36 + * The Japanese calendar is identical to the Gregorian calendar in all respects
    1.37 + * except for the year and era.  The ascension of each  emperor to the throne
    1.38 + * begins a new era, and the years of that era are numbered starting with the
    1.39 + * year of ascension as year 1.
    1.40 + * <p>
    1.41 + * Note that in the year of an imperial ascension, there are two possible sets
    1.42 + * of year and era values: that for the old era and for the new.  For example, a
    1.43 + * new era began on January 7, 1989 AD.  Strictly speaking, the first six days
    1.44 + * of that year were in the Showa era, e.g. "January 6, 64 Showa", while the rest
    1.45 + * of the year was in the Heisei era, e.g. "January 7, 1 Heisei".  This class
    1.46 + * handles this distinction correctly when computing dates.  However, in lenient
    1.47 + * mode either form of date is acceptable as input. 
    1.48 + * <p>
    1.49 + * In modern times, eras have started on January 8, 1868 AD, Gregorian (Meiji),
    1.50 + * July 30, 1912 (Taisho), December 25, 1926 (Showa), and January 7, 1989 (Heisei).  Constants
    1.51 + * for these eras, suitable for use in the <code>UCAL_ERA</code> field, are provided
    1.52 + * in this class.  Note that the <em>number</em> used for each era is more or
    1.53 + * less arbitrary.  Currently, the era starting in 1053 AD is era #0; however this
    1.54 + * may change in the future as we add more historical data.  Use the predefined
    1.55 + * constants rather than using actual, absolute numbers.
    1.56 + * <p>
    1.57 + * @internal
    1.58 + */
    1.59 +class JapaneseCalendar : public GregorianCalendar {
    1.60 +public:
    1.61 +
    1.62 +    /**
    1.63 +     * Useful constants for JapaneseCalendar.  
    1.64 +     * @internal
    1.65 +     */
    1.66 +    U_I18N_API static uint32_t U_EXPORT2 getCurrentEra(void); // the current era
    1.67 +
    1.68 +    /**
    1.69 +     * Constructs a JapaneseCalendar based on the current time in the default time zone
    1.70 +     * with the given locale.
    1.71 +     *
    1.72 +     * @param aLocale  The given locale.
    1.73 +     * @param success  Indicates the status of JapaneseCalendar object construction.
    1.74 +     *                 Returns U_ZERO_ERROR if constructed successfully.
    1.75 +     * @stable ICU 2.0
    1.76 +     */
    1.77 +    JapaneseCalendar(const Locale& aLocale, UErrorCode& success);
    1.78 +
    1.79 +
    1.80 +    /**
    1.81 +     * Destructor
    1.82 +     * @internal
    1.83 +     */
    1.84 +    virtual ~JapaneseCalendar();
    1.85 +
    1.86 +    /**
    1.87 +     * Copy constructor
    1.88 +     * @param source    the object to be copied.
    1.89 +     * @internal
    1.90 +     */
    1.91 +    JapaneseCalendar(const JapaneseCalendar& source);
    1.92 +
    1.93 +    /**
    1.94 +     * Default assignment operator
    1.95 +     * @param right    the object to be copied.
    1.96 +     * @internal
    1.97 +     */
    1.98 +    JapaneseCalendar& operator=(const JapaneseCalendar& right);
    1.99 +
   1.100 +    /**
   1.101 +     * Create and return a polymorphic copy of this calendar.
   1.102 +     * @return    return a polymorphic copy of this calendar.
   1.103 +     * @internal
   1.104 +     */
   1.105 +    virtual Calendar* clone(void) const;
   1.106 +
   1.107 +    /**
   1.108 +     * Return the extended year defined by the current fields.  In the 
   1.109 +     * Japanese calendar case, this is equal to the equivalent extended Gregorian year.
   1.110 +     * @internal
   1.111 +     */
   1.112 +    virtual int32_t handleGetExtendedYear();
   1.113 +
   1.114 +    /**
   1.115 +     * Return the maximum value that this field could have, given the current date.
   1.116 +     * @internal
   1.117 +     */
   1.118 +    virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
   1.119 +
   1.120 +
   1.121 +public:
   1.122 +    /**
   1.123 +     * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
   1.124 +     * override. This method is to implement a simple version of RTTI, since not all C++
   1.125 +     * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
   1.126 +     * this method.
   1.127 +     *
   1.128 +     * @return   The class ID for this object. All objects of a given class have the
   1.129 +     *           same class ID. Objects of other classes have different class IDs.
   1.130 +     * @internal
   1.131 +     */
   1.132 +    virtual UClassID getDynamicClassID(void) const;
   1.133 +
   1.134 +    /**
   1.135 +     * Return the class ID for this class. This is useful only for comparing to a return
   1.136 +     * value from getDynamicClassID(). For example:
   1.137 +     *
   1.138 +     *      Base* polymorphic_pointer = createPolymorphicObject();
   1.139 +     *      if (polymorphic_pointer->getDynamicClassID() ==
   1.140 +     *          Derived::getStaticClassID()) ...
   1.141 +     *
   1.142 +     * @return   The class ID for all objects of this class.
   1.143 +     * @internal
   1.144 +     */
   1.145 +    U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
   1.146 +
   1.147 +    /**
   1.148 +     * return the calendar type, "japanese".
   1.149 +     *
   1.150 +     * @return calendar type
   1.151 +     * @internal
   1.152 +     */
   1.153 +    virtual const char * getType() const;
   1.154 +
   1.155 +    /**
   1.156 +     * @return FALSE - no default century in Japanese
   1.157 +     * @internal 
   1.158 +     */
   1.159 +    virtual UBool haveDefaultCentury() const;
   1.160 +
   1.161 +    /**
   1.162 +     * Not used - no default century.
   1.163 +     * @internal
   1.164 +     */
   1.165 +    virtual UDate defaultCenturyStart() const;
   1.166 +    /**
   1.167 +     * Not used - no default century.
   1.168 +     * @internal
   1.169 +     */
   1.170 +    virtual int32_t defaultCenturyStartYear() const;
   1.171 +
   1.172 +private:
   1.173 +    JapaneseCalendar(); // default constructor not implemented
   1.174 +
   1.175 +protected:
   1.176 +    /** 
   1.177 +     * Calculate the era for internal computation
   1.178 +     * @internal
   1.179 +     */
   1.180 +    virtual int32_t internalGetEra() const;
   1.181 +
   1.182 +    /**
   1.183 +     * Compute fields from the JD
   1.184 +     * @internal
   1.185 +     */
   1.186 +    virtual void handleComputeFields(int32_t julianDay, UErrorCode& status);
   1.187 +
   1.188 +    /**
   1.189 +     * Calculate the limit for a specified type of limit and field
   1.190 +     * @internal
   1.191 +     */
   1.192 +    virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
   1.193 +
   1.194 +    /***
   1.195 +     * Called by computeJulianDay.  Returns the default month (0-based) for the year,
   1.196 +     * taking year and era into account.  Will return the first month of the given era, if 
   1.197 +     * the current year is an ascension year.
   1.198 +     * @param eyear the extended year
   1.199 +     * @internal
   1.200 +     */
   1.201 +    virtual int32_t getDefaultMonthInYear(int32_t eyear);
   1.202 +
   1.203 +    /***
   1.204 +     * Called by computeJulianDay.  Returns the default day (1-based) for the month,
   1.205 +     * taking currently-set year and era into account.  Will return the first day of the given
   1.206 +     * era, if the current month is an ascension year and month.
   1.207 +     * @param eyear the extended year
   1.208 +     * @param mon the month in the year
   1.209 +     * @internal
   1.210 +     */
   1.211 +    virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month);
   1.212 +};
   1.213 +
   1.214 +U_NAMESPACE_END
   1.215 +
   1.216 +#endif /* #if !UCONFIG_NO_FORMATTING */
   1.217 +
   1.218 +#endif
   1.219 +//eof
   1.220 +

mercurial