1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho ***************************************************************************** 385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * Copyright (C) 2003-2008, International Business Machines Corporation 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and others. All Rights Reserved. 585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho ***************************************************************************** 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * File INDIANCAL.H 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ***************************************************************************** 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef INDIANCAL_H 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define INDIANCAL_H 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h" 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/calendar.h" 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Concrete class which provides the Indian calendar. 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <P> 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>IndianCalendar</code> is a subclass of <code>Calendar</code> 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that numbers years since the begining of SAKA ERA. This is the civil calendar 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * which is accepted by government of India as Indian National Calendar. 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The two calendars most widely used in India today are the Vikrama calendar 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * followed in North India and the Shalivahana or Saka calendar which is followed 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * in South India and Maharashtra. 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * A variant of the Shalivahana Calendar was reformed and standardized as the 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Indian National calendar in 1957. 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p> 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Some details of Indian National Calendar (to be implemented) : 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The Months 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Month Length Start date (Gregorian) 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * ================================================= 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1 Chaitra 30/31 March 22* 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 2 Vaisakha 31 April 21 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 3 Jyaistha 31 May 22 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 4 Asadha 31 June 22 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 5 Sravana 31 July 23 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 6 Bhadra 31 August 23 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 7 Asvina 30 September 23 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 8 Kartika 30 October 23 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 9 Agrahayana 30 November 22 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 10 Pausa 30 December 22 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 11 Magha 30 January 21 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 12 Phalguna 30 February 20 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * In leap years, Chaitra has 31 days and starts on March 21 instead. 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The leap years of Gregorian calendar and Indian National Calendar are in synchornization. 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * So When its a leap year in Gregorian calendar then Chaitra has 31 days. 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The Years 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Years are counted in the Saka Era, which starts its year 0 in 78AD (by gregorian calendar). 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * So for eg. 9th June 2006 by Gregorian Calendar, is same as 19th of Jyaistha in 1928 of Saka 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * era by Indian National Calendar. 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p> 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The Indian Calendar has only one allowable era: <code>Saka Era</code>. If the 62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * calendar is not in lenient mode (see <code>setLenient</code>), dates before 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1/1/1 Saka Era are rejected with an <code>IllegalArgumentException</code>. 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p> 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 6985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Hoclass IndianCalendar : public Calendar { 7085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Hopublic: 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Useful constants for IndianCalendar. 73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru enum EEras { 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Chaitra, the 1st month of the Indian year. 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru CHAITRA, 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Vaisakha, the 2nd month of the Indian year. 83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru VAISAKHA, 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Jyaistha, the 3rd month of the Indian year. 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru JYAISTHA, 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Asadha, the 4th month of the Indian year. 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ASADHA, 95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Sravana, the 5th month of the Indian year. 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru SRAVANA, 100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Bhadra the 6th month of the Indian year 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru BHADRA, 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for the Asvina, the 7th month of the Indian year. 108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ASVINA, 110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Kartika, the 8th month of the Indian year. 113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru KARTIKA, 115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Agrahayana, the 9th month of the Indian year. 118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru AGRAHAYANA, 120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Pausa, the 10th month of the Indian year. 123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru PAUSA, 125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Magha, the 11th month of the Indian year. 128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru MAGHA, 130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constant for Phalguna, the 12th month of the Indian year. 133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru PHALGUNA 135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }; 136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //------------------------------------------------------------------------- 138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // Constructors... 139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //------------------------------------------------------------------------- 140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Constructs an IndianCalendar based on the current time in the default time zone 143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * with the given locale. 144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param aLocale The given locale. 146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param success Indicates the status of IndianCalendar object construction. 147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns U_ZERO_ERROR if constructed successfully. 148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param beCivil Whether the calendar should be civil (default-TRUE) or religious (FALSE) 149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru IndianCalendar(const Locale& aLocale, UErrorCode &success); 152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Copy Constructor 155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru IndianCalendar(const IndianCalendar& other); 158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Destructor. 161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual ~IndianCalendar(); 164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Determines whether this object uses the fixed-cycle Indian civil calendar 167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * or an approximation of the religious, astronomical calendar. 168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param beCivil <code>CIVIL</code> to use the civil calendar, 170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>ASTRONOMICAL</code> to use the astronomical calendar. 171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //void setCivil(ECivil beCivil, UErrorCode &status); 174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns <code>true</code> if this object is using the fixed-cycle civil 177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * calendar, or <code>false</code> if using the religious, astronomical 178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * calendar. 179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //UBool isCivil(); 182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // TODO: copy c'tor, etc 185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // clone 187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual Calendar* clone() const; 188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru private: 190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Determine whether a year is the gregorian year a leap year 192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //static UBool isGregorianLeap(int32_t year); 194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //---------------------------------------------------------------------- 195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // Calendar framework 196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //---------------------------------------------------------------------- 197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru protected: 198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const; 202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the length (in days) of the given month. 205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param year The year in Saka era 207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param year The month(0-based) in Indian year 208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const; 211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the number of days in the given Indian year 214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int32_t handleGetYearLength(int32_t extendedYear) const; 217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //------------------------------------------------------------------------- 219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // Functions for converting from field values to milliseconds.... 220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //------------------------------------------------------------------------- 221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // Return JD of start of given month/year 223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const; 227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //------------------------------------------------------------------------- 229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // Functions for converting from milliseconds to field values 230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru //------------------------------------------------------------------------- 231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int32_t handleGetExtendedYear(); 236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Override Calendar to compute several fields specific to the Indian 239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * calendar system. These are: 240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul><li>ERA 242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>YEAR 243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>MONTH 244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>DAY_OF_MONTH 245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>DAY_OF_YEAR 246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>EXTENDED_YEAR</ul> 247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this 249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * method is called. The getGregorianXxx() methods return Gregorian 250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * calendar equivalents for the given Julian day. 251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void handleComputeFields(int32_t julianDay, UErrorCode &status); 254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // UObject stuff 256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru public: 257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return The class ID for this object. All objects of a given class have the 259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * same class ID. Objects of other classes have different class IDs. 260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UClassID getDynamicClassID(void) const; 263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the class ID for this class. This is useful only for comparing to a return 266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * value from getDynamicClassID(). For example: 267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Base* polymorphic_pointer = createPolymorphicObject(); 269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * if (polymorphic_pointer->getDynamicClassID() == 270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Derived::getStaticClassID()) ... 271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return The class ID for all objects of this class. 273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 27585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void); 276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return the calendar type, "buddhist". 279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return calendar type 281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual const char * getType() const; 284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 28585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Hoprivate: 286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru IndianCalendar(); // default constructor not implemented 287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // Default century. 28985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Hoprotected: 290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (Overrides Calendar) Return true if the current date for this Calendar is in 293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Daylight Savings Time. Recognizes DST_OFFSET, if it is set. 294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Fill-in parameter which receives the status of this operation. 296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return True if the current date for this Calendar is in Daylight Savings Time, 297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * false, otherwise. 298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UBool inDaylightTime(UErrorCode& status) const; 301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns TRUE because the Indian Calendar does have a default century 305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UBool haveDefaultCentury() const; 308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the date of the start of the default century 311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return start of century - in milliseconds since epoch, 1970 312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UDate defaultCenturyStart() const; 315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the year in which the default century begins 318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int32_t defaultCenturyStartYear() const; 321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru private: // default century stuff. 323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The system maintains a static default century start date. This is initialized 325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the first time it is used. Before then, it is set to SYSTEM_DEFAULT_CENTURY to 326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * indicate an uninitialized state. Once the system default century date and year 327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are set, they do not change. 328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UDate fgSystemDefaultCenturyStart; 330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * See documentation for systemDefaultCenturyStart. 333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t fgSystemDefaultCenturyStartYear; 335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Default value that indicates the defaultCenturyStartYear is unitialized 338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static const int32_t fgSystemDefaultCenturyYear; 340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * start of default century, as a date 343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static const UDate fgSystemDefaultCentury; 345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the beginning date of the 100-year window that dates 348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * with 2-digit years are considered to fall within. 349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UDate internalGetDefaultCenturyStart(void) const; 351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the first year of the 100-year window that dates with 354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 2-digit years are considered to fall within. 355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t internalGetDefaultCenturyStartYear(void) const; 357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Initializes the 100-year window that dates with 2-digit years 360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are considered to fall within so that its start date is 80 years 361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * before the current time. 362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static void initializeSystemDefaultCentury(void); 364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END 367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 373