Home | History | Annotate | Download | only in i18n
      1 /*
      2 *******************************************************************************
      3 * Copyright (C) 2003 - 2008, International Business Machines Corporation and  *
      4 * others. All Rights Reserved.                                                *
      5 *******************************************************************************
      6 */
      7 
      8 #ifndef CECAL_H
      9 #define CECAL_H
     10 
     11 #include "unicode/utypes.h"
     12 
     13 #if !UCONFIG_NO_FORMATTING
     14 
     15 #include "unicode/calendar.h"
     16 
     17 U_NAMESPACE_BEGIN
     18 
     19 /**
     20  * Base class for EthiopicCalendar and CopticCalendar.
     21  * @internal
     22  */
     23 class U_I18N_API CECalendar : public Calendar {
     24 
     25 protected:
     26     //-------------------------------------------------------------------------
     27     // Constructors...
     28     //-------------------------------------------------------------------------
     29 
     30     /**
     31      * Constructs a CECalendar based on the current time in the default time zone
     32      * with the given locale with the Julian epoch offiset
     33      *
     34      * @param aLocale  The given locale.
     35      * @param success  Indicates the status of CECalendar object construction.
     36      *                 Returns U_ZERO_ERROR if constructed successfully.
     37      * @internal
     38      */
     39     CECalendar(const Locale& aLocale, UErrorCode& success);
     40 
     41     /**
     42      * Copy Constructor
     43      * @internal
     44      */
     45     CECalendar (const CECalendar& other);
     46 
     47     /**
     48      * Destructor.
     49      * @internal
     50      */
     51     virtual ~CECalendar();
     52 
     53     /**
     54      * Default assignment operator
     55      * @param right    Calendar object to be copied
     56      * @internal
     57      */
     58     CECalendar& operator=(const CECalendar& right);
     59 
     60 protected:
     61     //-------------------------------------------------------------------------
     62     // Calendar framework
     63     //-------------------------------------------------------------------------
     64 
     65     /**
     66      * Return JD of start of given month/extended year
     67      * @internal
     68      */
     69     virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const;
     70 
     71     /**
     72      * Calculate the limit for a specified type of limit and field
     73      * @internal
     74      */
     75     virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
     76 
     77     /**
     78      * (Overrides Calendar) Return true if the current date for this Calendar is in
     79      * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
     80      *
     81      * @param status Fill-in parameter which receives the status of this operation.
     82      * @return   True if the current date for this Calendar is in Daylight Savings Time,
     83      *           false, otherwise.
     84      * @internal
     85      */
     86     virtual UBool inDaylightTime(UErrorCode&) const;
     87 
     88     /**
     89      * Returns TRUE because Coptic/Ethiopic Calendar does have a default century
     90      * @internal
     91      */
     92     virtual UBool haveDefaultCentury() const;
     93 
     94 protected:
     95     /**
     96      * The Coptic and Ethiopic calendars differ only in their epochs.
     97      * This method must be implemented by CECalendar subclasses to
     98      * return the date offset from Julian
     99      * @internal
    100      */
    101     virtual int32_t getJDEpochOffset() const = 0;
    102 
    103     /**
    104      * Convert an Coptic/Ethiopic year, month, and day to a Julian day.
    105      *
    106      * @param year the extended year
    107      * @param month the month
    108      * @param day the day
    109      * @param jdEpochOffset the epoch offset from Julian epoch
    110      * @return Julian day
    111      * @internal
    112      */
    113     static int32_t ceToJD(int32_t year, int32_t month, int32_t date,
    114         int32_t jdEpochOffset);
    115 
    116     /**
    117      * Convert a Julian day to an Coptic/Ethiopic year, month and day
    118      *
    119      * @param julianDay the Julian day
    120      * @param jdEpochOffset the epoch offset from Julian epoch
    121      * @param year receives the extended year
    122      * @param month receives the month
    123      * @param date receives the day
    124      * @internal
    125      */
    126     static void jdToCE(int32_t julianDay, int32_t jdEpochOffset,
    127         int32_t& year, int32_t& month, int32_t& day);
    128 };
    129 
    130 U_NAMESPACE_END
    131 
    132 #endif /* #if !UCONFIG_NO_FORMATTING */
    133 #endif
    134 //eof
    135