michael@0: /* michael@0: ***************************************************************************** michael@0: * Copyright (C) 2003-2008, International Business Machines Corporation michael@0: * and others. All Rights Reserved. michael@0: ***************************************************************************** michael@0: * michael@0: * File INDIANCAL.H michael@0: ***************************************************************************** michael@0: */ michael@0: michael@0: #ifndef INDIANCAL_H michael@0: #define INDIANCAL_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/calendar.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /** michael@0: * Concrete class which provides the Indian calendar. michael@0: *
michael@0: * IndianCalendar
is a subclass of Calendar
michael@0: * that numbers years since the begining of SAKA ERA. This is the civil calendar
michael@0: * which is accepted by government of India as Indian National Calendar.
michael@0: * The two calendars most widely used in India today are the Vikrama calendar
michael@0: * followed in North India and the Shalivahana or Saka calendar which is followed
michael@0: * in South India and Maharashtra.
michael@0:
michael@0: * A variant of the Shalivahana Calendar was reformed and standardized as the
michael@0: * Indian National calendar in 1957.
michael@0: *
michael@0: * Some details of Indian National Calendar (to be implemented) : michael@0: * The Months michael@0: * Month Length Start date (Gregorian) michael@0: * ================================================= michael@0: * 1 Chaitra 30/31 March 22* michael@0: * 2 Vaisakha 31 April 21 michael@0: * 3 Jyaistha 31 May 22 michael@0: * 4 Asadha 31 June 22 michael@0: * 5 Sravana 31 July 23 michael@0: * 6 Bhadra 31 August 23 michael@0: * 7 Asvina 30 September 23 michael@0: * 8 Kartika 30 October 23 michael@0: * 9 Agrahayana 30 November 22 michael@0: * 10 Pausa 30 December 22 michael@0: * 11 Magha 30 January 21 michael@0: * 12 Phalguna 30 February 20 michael@0: michael@0: * In leap years, Chaitra has 31 days and starts on March 21 instead. michael@0: * The leap years of Gregorian calendar and Indian National Calendar are in synchornization. michael@0: * So When its a leap year in Gregorian calendar then Chaitra has 31 days. michael@0: * michael@0: * The Years michael@0: * Years are counted in the Saka Era, which starts its year 0 in 78AD (by gregorian calendar). michael@0: * So for eg. 9th June 2006 by Gregorian Calendar, is same as 19th of Jyaistha in 1928 of Saka michael@0: * era by Indian National Calendar. michael@0: *
michael@0: * The Indian Calendar has only one allowable era: Saka Era
. If the
michael@0: * calendar is not in lenient mode (see setLenient
), dates before
michael@0: * 1/1/1 Saka Era are rejected with an IllegalArgumentException
.
michael@0: *
michael@0: * @internal
michael@0: */
michael@0:
michael@0:
michael@0: class IndianCalendar : public Calendar {
michael@0: public:
michael@0: /**
michael@0: * Useful constants for IndianCalendar.
michael@0: * @internal
michael@0: */
michael@0: enum EEras {
michael@0: /**
michael@0: * Constant for Chaitra, the 1st month of the Indian year.
michael@0: */
michael@0: CHAITRA,
michael@0:
michael@0: /**
michael@0: * Constant for Vaisakha, the 2nd month of the Indian year.
michael@0: */
michael@0: VAISAKHA,
michael@0:
michael@0: /**
michael@0: * Constant for Jyaistha, the 3rd month of the Indian year.
michael@0: */
michael@0: JYAISTHA,
michael@0:
michael@0: /**
michael@0: * Constant for Asadha, the 4th month of the Indian year.
michael@0: */
michael@0: ASADHA,
michael@0:
michael@0: /**
michael@0: * Constant for Sravana, the 5th month of the Indian year.
michael@0: */
michael@0: SRAVANA,
michael@0:
michael@0: /**
michael@0: * Constant for Bhadra the 6th month of the Indian year
michael@0: */
michael@0: BHADRA,
michael@0:
michael@0: /**
michael@0: * Constant for the Asvina, the 7th month of the Indian year.
michael@0: */
michael@0: ASVINA,
michael@0:
michael@0: /**
michael@0: * Constant for Kartika, the 8th month of the Indian year.
michael@0: */
michael@0: KARTIKA,
michael@0:
michael@0: /**
michael@0: * Constant for Agrahayana, the 9th month of the Indian year.
michael@0: */
michael@0: AGRAHAYANA,
michael@0:
michael@0: /**
michael@0: * Constant for Pausa, the 10th month of the Indian year.
michael@0: */
michael@0: PAUSA,
michael@0:
michael@0: /**
michael@0: * Constant for Magha, the 11th month of the Indian year.
michael@0: */
michael@0: MAGHA,
michael@0:
michael@0: /**
michael@0: * Constant for Phalguna, the 12th month of the Indian year.
michael@0: */
michael@0: PHALGUNA
michael@0: };
michael@0:
michael@0: //-------------------------------------------------------------------------
michael@0: // Constructors...
michael@0: //-------------------------------------------------------------------------
michael@0:
michael@0: /**
michael@0: * Constructs an IndianCalendar based on the current time in the default time zone
michael@0: * with the given locale.
michael@0: *
michael@0: * @param aLocale The given locale.
michael@0: * @param success Indicates the status of IndianCalendar object construction.
michael@0: * Returns U_ZERO_ERROR if constructed successfully.
michael@0: * @param beCivil Whether the calendar should be civil (default-TRUE) or religious (FALSE)
michael@0: * @internal
michael@0: */
michael@0: IndianCalendar(const Locale& aLocale, UErrorCode &success);
michael@0:
michael@0: /**
michael@0: * Copy Constructor
michael@0: * @internal
michael@0: */
michael@0: IndianCalendar(const IndianCalendar& other);
michael@0:
michael@0: /**
michael@0: * Destructor.
michael@0: * @internal
michael@0: */
michael@0: virtual ~IndianCalendar();
michael@0:
michael@0: /**
michael@0: * Determines whether this object uses the fixed-cycle Indian civil calendar
michael@0: * or an approximation of the religious, astronomical calendar.
michael@0: *
michael@0: * @param beCivil CIVIL
to use the civil calendar,
michael@0: * ASTRONOMICAL
to use the astronomical calendar.
michael@0: * @internal
michael@0: */
michael@0: //void setCivil(ECivil beCivil, UErrorCode &status);
michael@0:
michael@0: /**
michael@0: * Returns true
if this object is using the fixed-cycle civil
michael@0: * calendar, or false
if using the religious, astronomical
michael@0: * calendar.
michael@0: * @internal
michael@0: */
michael@0: //UBool isCivil();
michael@0:
michael@0:
michael@0: // TODO: copy c'tor, etc
michael@0:
michael@0: // clone
michael@0: virtual Calendar* clone() const;
michael@0:
michael@0: private:
michael@0: /**
michael@0: * Determine whether a year is the gregorian year a leap year
michael@0: */
michael@0: //static UBool isGregorianLeap(int32_t year);
michael@0: //----------------------------------------------------------------------
michael@0: // Calendar framework
michael@0: //----------------------------------------------------------------------
michael@0: protected:
michael@0: /**
michael@0: * @internal
michael@0: */
michael@0: virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
michael@0:
michael@0: /**
michael@0: * Return the length (in days) of the given month.
michael@0: *
michael@0: * @param year The year in Saka era
michael@0: * @param year The month(0-based) in Indian year
michael@0: * @internal
michael@0: */
michael@0: virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const;
michael@0:
michael@0: /**
michael@0: * Return the number of days in the given Indian year
michael@0: * @internal
michael@0: */
michael@0: virtual int32_t handleGetYearLength(int32_t extendedYear) const;
michael@0:
michael@0: //-------------------------------------------------------------------------
michael@0: // Functions for converting from field values to milliseconds....
michael@0: //-------------------------------------------------------------------------
michael@0:
michael@0: // Return JD of start of given month/year
michael@0: /**
michael@0: * @internal
michael@0: */
michael@0: virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const;
michael@0:
michael@0: //-------------------------------------------------------------------------
michael@0: // Functions for converting from milliseconds to field values
michael@0: //-------------------------------------------------------------------------
michael@0:
michael@0: /**
michael@0: * @internal
michael@0: */
michael@0: virtual int32_t handleGetExtendedYear();
michael@0:
michael@0: /**
michael@0: * Override Calendar to compute several fields specific to the Indian
michael@0: * calendar system. These are:
michael@0: *
michael@0: *