annotate modules/javafx.web/src/main/native/Source/ThirdParty/icu/source/i18n/persncal.h @ 11038:20a8447c71c6

8207159: Update ICU to version 62.1 Reviewed-by: mbilla, kcr, ghb
author arajkumar
date Fri, 24 Aug 2018 15:06:40 +0530
parents fee4ef5c87df
children
rev   line source
arajkumar@11038 1 // © 2016 and later: Unicode, Inc. and others.
arajkumar@11038 2 // License & terms of use: http://www.unicode.org/copyright.html
ghb@10550 3 /*
ghb@10550 4 ******************************************************************************
arajkumar@11038 5 * Copyright (C) 2003-2013, International Business Machines Corporation
ghb@10550 6 * and others. All Rights Reserved.
ghb@10550 7 ******************************************************************************
ghb@10550 8 *
ghb@10550 9 * File PERSNCAL.H
ghb@10550 10 *
ghb@10550 11 * Modification History:
ghb@10550 12 *
ghb@10550 13 * Date Name Description
ghb@10550 14 * 9/23/2003 mehran posted to icu-design
ghb@10550 15 *****************************************************************************
ghb@10550 16 */
ghb@10550 17
ghb@10550 18 #ifndef PERSNCAL_H
ghb@10550 19 #define PERSNCAL_H
ghb@10550 20
ghb@10550 21 #include "unicode/utypes.h"
ghb@10550 22
ghb@10550 23 #if !UCONFIG_NO_FORMATTING
ghb@10550 24
ghb@10550 25 #include "unicode/calendar.h"
ghb@10550 26
ghb@10550 27 U_NAMESPACE_BEGIN
ghb@10550 28
ghb@10550 29 /**
ghb@10550 30 * <code>PersianCalendar</code> is a subclass of <code>Calendar</code>
ghb@10550 31 * that implements the Persian calendar. It is used as the official
ghb@10550 32 * calendar in Iran. This calendar is also known as the "Hijri Shamsi"
ghb@10550 33 * calendar, since it starts at the time of Mohammed's emigration (or
ghb@10550 34 * "hijra") to Medinah on Thursday, July 15, 622 AD (Julian) and is a
ghb@10550 35 * solar calendar system (or "shamsi").
ghb@10550 36 * <p>
ghb@10550 37 * The Persian calendar is strictly solar, and thus a Persian year has twelve
ghb@10550 38 * solar months. A Persian year is about 365 days long, except in leap years
ghb@10550 39 * which is 366 days long.
ghb@10550 40 * <p>
ghb@10550 41 * The six first months of Persian Calendar are 31 days long. The next five
ghb@10550 42 * months are 30 days long. The last month is 29 days long in normal years,
ghb@10550 43 * and 30 days long in leap years.
ghb@10550 44 *
ghb@10550 45 * @see GregorianCalendar
ghb@10550 46 *
ghb@10550 47 * @author Mehran Mehr
ghb@10550 48 * @internal
ghb@10550 49 */
ghb@10550 50 class PersianCalendar : public Calendar {
ghb@10550 51 public:
ghb@10550 52 //-------------------------------------------------------------------------
ghb@10550 53 // Constants...
ghb@10550 54 //-------------------------------------------------------------------------
ghb@10550 55 /**
ghb@10550 56 * Constants for the months
ghb@10550 57 * @internal
ghb@10550 58 */
ghb@10550 59 enum EMonths {
ghb@10550 60 /**
ghb@10550 61 * Constant for Farvardin, the 1st month of the Persian year.
ghb@10550 62 * @internal
ghb@10550 63 */
ghb@10550 64 FARVARDIN = 0,
ghb@10550 65
ghb@10550 66 /**
ghb@10550 67 * Constant for Ordibehesht, the 2nd month of the Persian year.
ghb@10550 68 * @internal
ghb@10550 69 */
ghb@10550 70 ORDIBEHESHT = 1,
ghb@10550 71
ghb@10550 72 /**
ghb@10550 73 * Constant for Khordad, the 3rd month of the Persian year.
ghb@10550 74 * @internal
ghb@10550 75 */
ghb@10550 76 KHORDAD = 2,
ghb@10550 77
ghb@10550 78 /**
ghb@10550 79 * Constant for Tir, the 4th month of the Persian year.
ghb@10550 80 * @internal
ghb@10550 81 */
ghb@10550 82 TIR = 3,
ghb@10550 83
ghb@10550 84 /**
ghb@10550 85 * Constant for Mordad, the 5th month of the Persian year.
ghb@10550 86 * @internal
ghb@10550 87 */
ghb@10550 88 MORDAD = 4,
ghb@10550 89
ghb@10550 90 /**
ghb@10550 91 * Constant for Shahrivar, the 6th month of the Persian year.
ghb@10550 92 * @internal
ghb@10550 93 */
ghb@10550 94 SHAHRIVAR = 5,
ghb@10550 95
ghb@10550 96 /**
ghb@10550 97 * Constant for Mehr, the 7th month of the Persian year.
ghb@10550 98 * @internal
ghb@10550 99 */
ghb@10550 100 MEHR = 6,
ghb@10550 101
ghb@10550 102 /**
ghb@10550 103 * Constant for Aban, the 8th month of the Persian year.
ghb@10550 104 * @internal
ghb@10550 105 */
ghb@10550 106 ABAN = 7,
ghb@10550 107
ghb@10550 108 /**
ghb@10550 109 * Constant for Azar, the 9th month of the Persian year.
ghb@10550 110 * @internal
ghb@10550 111 */
ghb@10550 112 AZAR = 8,
ghb@10550 113
ghb@10550 114 /**
ghb@10550 115 * Constant for Dei, the 10th month of the Persian year.
ghb@10550 116 * @internal
ghb@10550 117 */
ghb@10550 118 DEI = 9,
ghb@10550 119
ghb@10550 120 /**
ghb@10550 121 * Constant for Bahman, the 11th month of the Persian year.
ghb@10550 122 * @internal
ghb@10550 123 */
ghb@10550 124 BAHMAN = 10,
ghb@10550 125
ghb@10550 126 /**
ghb@10550 127 * Constant for Esfand, the 12th month of the Persian year.
ghb@10550 128 * @internal
ghb@10550 129 */
ghb@10550 130 ESFAND = 11,
ghb@10550 131
ghb@10550 132 PERSIAN_MONTH_MAX
ghb@10550 133 };
ghb@10550 134
ghb@10550 135
ghb@10550 136
ghb@10550 137 //-------------------------------------------------------------------------
ghb@10550 138 // Constructors...
ghb@10550 139 //-------------------------------------------------------------------------
ghb@10550 140
ghb@10550 141 /**
ghb@10550 142 * Constructs a PersianCalendar based on the current time in the default time zone
ghb@10550 143 * with the given locale.
ghb@10550 144 *
ghb@10550 145 * @param aLocale The given locale.
ghb@10550 146 * @param success Indicates the status of PersianCalendar object construction.
ghb@10550 147 * Returns U_ZERO_ERROR if constructed successfully.
ghb@10550 148 * @internal
ghb@10550 149 */
ghb@10550 150 PersianCalendar(const Locale& aLocale, UErrorCode &success);
ghb@10550 151
ghb@10550 152 /**
ghb@10550 153 * Copy Constructor
ghb@10550 154 * @internal
ghb@10550 155 */
ghb@10550 156 PersianCalendar(const PersianCalendar& other);
ghb@10550 157
ghb@10550 158 /**
ghb@10550 159 * Destructor.
ghb@10550 160 * @internal
ghb@10550 161 */
ghb@10550 162 virtual ~PersianCalendar();
ghb@10550 163
ghb@10550 164 // TODO: copy c'tor, etc
ghb@10550 165
ghb@10550 166 // clone
ghb@10550 167 virtual Calendar* clone() const;
ghb@10550 168
ghb@10550 169 private:
ghb@10550 170 /**
ghb@10550 171 * Determine whether a year is a leap year in the Persian calendar
ghb@10550 172 */
ghb@10550 173 static UBool isLeapYear(int32_t year);
ghb@10550 174
ghb@10550 175 /**
ghb@10550 176 * Return the day # on which the given year starts. Days are counted
ghb@10550 177 * from the Hijri epoch, origin 0.
ghb@10550 178 */
ghb@10550 179 int32_t yearStart(int32_t year);
ghb@10550 180
ghb@10550 181 /**
ghb@10550 182 * Return the day # on which the given month starts. Days are counted
ghb@10550 183 * from the Hijri epoch, origin 0.
ghb@10550 184 *
ghb@10550 185 * @param year The hijri shamsi year
ghb@10550 186 * @param year The hijri shamsi month, 0-based
ghb@10550 187 */
ghb@10550 188 int32_t monthStart(int32_t year, int32_t month) const;
ghb@10550 189
ghb@10550 190 //----------------------------------------------------------------------
ghb@10550 191 // Calendar framework
ghb@10550 192 //----------------------------------------------------------------------
ghb@10550 193 protected:
ghb@10550 194 /**
ghb@10550 195 * @internal
ghb@10550 196 */
ghb@10550 197 virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
ghb@10550 198
ghb@10550 199 /**
ghb@10550 200 * Return the length (in days) of the given month.
ghb@10550 201 *
ghb@10550 202 * @param year The hijri shamsi year
ghb@10550 203 * @param year The hijri shamsi month, 0-based
ghb@10550 204 * @internal
ghb@10550 205 */
ghb@10550 206 virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const;
ghb@10550 207
ghb@10550 208 /**
ghb@10550 209 * Return the number of days in the given Persian year
ghb@10550 210 * @internal
ghb@10550 211 */
ghb@10550 212 virtual int32_t handleGetYearLength(int32_t extendedYear) const;
ghb@10550 213
ghb@10550 214 //-------------------------------------------------------------------------
ghb@10550 215 // Functions for converting from field values to milliseconds....
ghb@10550 216 //-------------------------------------------------------------------------
ghb@10550 217
ghb@10550 218 // Return JD of start of given month/year
ghb@10550 219 /**
ghb@10550 220 * @internal
ghb@10550 221 */
ghb@10550 222 virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const;
ghb@10550 223
ghb@10550 224 //-------------------------------------------------------------------------
ghb@10550 225 // Functions for converting from milliseconds to field values
ghb@10550 226 //-------------------------------------------------------------------------
ghb@10550 227
ghb@10550 228 /**
ghb@10550 229 * @internal
ghb@10550 230 */
ghb@10550 231 virtual int32_t handleGetExtendedYear();
ghb@10550 232
ghb@10550 233 /**
ghb@10550 234 * Override Calendar to compute several fields specific to the Persian
ghb@10550 235 * calendar system. These are:
ghb@10550 236 *
ghb@10550 237 * <ul><li>ERA
ghb@10550 238 * <li>YEAR
ghb@10550 239 * <li>MONTH
ghb@10550 240 * <li>DAY_OF_MONTH
ghb@10550 241 * <li>DAY_OF_YEAR
ghb@10550 242 * <li>EXTENDED_YEAR</ul>
ghb@10550 243 *
ghb@10550 244 * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this
ghb@10550 245 * method is called. The getGregorianXxx() methods return Gregorian
ghb@10550 246 * calendar equivalents for the given Julian day.
ghb@10550 247 * @internal
ghb@10550 248 */
ghb@10550 249 virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
ghb@10550 250
ghb@10550 251 // UObject stuff
ghb@10550 252 public:
ghb@10550 253 /**
ghb@10550 254 * @return The class ID for this object. All objects of a given class have the
ghb@10550 255 * same class ID. Objects of other classes have different class IDs.
ghb@10550 256 * @internal
ghb@10550 257 */
ghb@10550 258 virtual UClassID getDynamicClassID(void) const;
ghb@10550 259
ghb@10550 260 /**
ghb@10550 261 * Return the class ID for this class. This is useful only for comparing to a return
ghb@10550 262 * value from getDynamicClassID(). For example:
ghb@10550 263 *
ghb@10550 264 * Base* polymorphic_pointer = createPolymorphicObject();
ghb@10550 265 * if (polymorphic_pointer->getDynamicClassID() ==
ghb@10550 266 * Derived::getStaticClassID()) ...
ghb@10550 267 *
ghb@10550 268 * @return The class ID for all objects of this class.
ghb@10550 269 * @internal
ghb@10550 270 */
ghb@10550 271 U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
ghb@10550 272
ghb@10550 273 /**
ghb@10550 274 * return the calendar type, "persian".
ghb@10550 275 *
ghb@10550 276 * @return calendar type
ghb@10550 277 * @internal
ghb@10550 278 */
ghb@10550 279 virtual const char * getType() const;
ghb@10550 280
ghb@10550 281 private:
ghb@10550 282 PersianCalendar(); // default constructor not implemented
ghb@10550 283
ghb@10550 284 protected:
ghb@10550 285
ghb@10550 286 /**
ghb@10550 287 * (Overrides Calendar) Return true if the current date for this Calendar is in
ghb@10550 288 * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
ghb@10550 289 *
ghb@10550 290 * @param status Fill-in parameter which receives the status of this operation.
ghb@10550 291 * @return True if the current date for this Calendar is in Daylight Savings Time,
ghb@10550 292 * false, otherwise.
ghb@10550 293 * @internal
ghb@10550 294 */
ghb@10550 295 virtual UBool inDaylightTime(UErrorCode& status) const;
ghb@10550 296
ghb@10550 297 /**
ghb@10550 298 * Returns TRUE because the Persian Calendar does have a default century
ghb@10550 299 * @internal
ghb@10550 300 */
ghb@10550 301 virtual UBool haveDefaultCentury() const;
ghb@10550 302
ghb@10550 303 /**
ghb@10550 304 * Returns the date of the start of the default century
ghb@10550 305 * @return start of century - in milliseconds since epoch, 1970
ghb@10550 306 * @internal
ghb@10550 307 */
ghb@10550 308 virtual UDate defaultCenturyStart() const;
ghb@10550 309
ghb@10550 310 /**
ghb@10550 311 * Returns the year in which the default century begins
ghb@10550 312 * @internal
ghb@10550 313 */
ghb@10550 314 virtual int32_t defaultCenturyStartYear() const;
ghb@10550 315 };
ghb@10550 316
ghb@10550 317 U_NAMESPACE_END
ghb@10550 318
ghb@10550 319 #endif
ghb@10550 320 #endif
ghb@10550 321
ghb@10550 322
ghb@10550 323