OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************** | 2 ******************************************************************************** |
3 * Copyright (C) 1997-2013, International Business Machines | 3 * Copyright (C) 1997-2014, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ******************************************************************************** | 5 ******************************************************************************** |
6 * | 6 * |
7 * File CALENDAR.H | 7 * File CALENDAR.H |
8 * | 8 * |
9 * Modification History: | 9 * Modification History: |
10 * | 10 * |
11 * Date Name Description | 11 * Date Name Description |
12 * 04/22/97 aliu Expanded and corrected comments and other header | 12 * 04/22/97 aliu Expanded and corrected comments and other header |
13 * contents. | 13 * contents. |
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 /** | 1706 /** |
1707 * Subclasses must override this to convert from week fields | 1707 * Subclasses must override this to convert from week fields |
1708 * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case | 1708 * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case |
1709 * where YEAR, EXTENDED_YEAR are not set. | 1709 * where YEAR, EXTENDED_YEAR are not set. |
1710 * The Calendar implementation assumes yearWoy is in extended gregorian form | 1710 * The Calendar implementation assumes yearWoy is in extended gregorian form |
1711 * @return the extended year, UCAL_EXTENDED_YEAR | 1711 * @return the extended year, UCAL_EXTENDED_YEAR |
1712 * @internal | 1712 * @internal |
1713 */ | 1713 */ |
1714 virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t
woy); | 1714 virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t
woy); |
1715 | 1715 |
| 1716 /** |
| 1717 * Validate a single field of this calendar. Subclasses should |
| 1718 * override this method to validate any calendar-specific fields. |
| 1719 * Generic fields can be handled by |
| 1720 * <code>Calendar::validateField()</code>. |
| 1721 * @see #validateField(int, int, int, int&) |
| 1722 * @internal |
| 1723 */ |
| 1724 virtual void validateField(UCalendarDateFields field, UErrorCode &status); |
| 1725 |
1716 #ifndef U_HIDE_INTERNAL_API | 1726 #ifndef U_HIDE_INTERNAL_API |
1717 /** | 1727 /** |
1718 * Compute the Julian day from fields. Will determine whether to use | 1728 * Compute the Julian day from fields. Will determine whether to use |
1719 * the JULIAN_DAY field directly, or other fields. | 1729 * the JULIAN_DAY field directly, or other fields. |
1720 * @return the julian day | 1730 * @return the julian day |
1721 * @internal | 1731 * @internal |
1722 */ | 1732 */ |
1723 int32_t computeJulianDay(); | 1733 int32_t computeJulianDay(); |
1724 | 1734 |
1725 /** | 1735 /** |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2147 */ | 2157 */ |
2148 UDate fTime; | 2158 UDate fTime; |
2149 | 2159 |
2150 /** | 2160 /** |
2151 * @see #setLenient | 2161 * @see #setLenient |
2152 */ | 2162 */ |
2153 UBool fLenient; | 2163 UBool fLenient; |
2154 | 2164 |
2155 /** | 2165 /** |
2156 * Time zone affects the time calculation done by Calendar. Calendar subclas
ses use | 2166 * Time zone affects the time calculation done by Calendar. Calendar subclas
ses use |
2157 * the time zone data to produce the local time. | 2167 * the time zone data to produce the local time. Always set; never NULL. |
2158 */ | 2168 */ |
2159 TimeZone* fZone; | 2169 TimeZone* fZone; |
2160 | 2170 |
2161 /** | 2171 /** |
2162 * Option for rpeated wall time | 2172 * Option for rpeated wall time |
2163 * @see #setRepeatedWallTimeOption | 2173 * @see #setRepeatedWallTimeOption |
2164 */ | 2174 */ |
2165 UCalendarWallTimeOption fRepeatedWallTime; | 2175 UCalendarWallTimeOption fRepeatedWallTime; |
2166 | 2176 |
2167 /** | 2177 /** |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 * Ensure that each field is within its valid range by calling {@link | 2296 * Ensure that each field is within its valid range by calling {@link |
2287 * #validateField(int, int&)} on each field that has been set. This method | 2297 * #validateField(int, int&)} on each field that has been set. This method |
2288 * should only be called if this calendar is not lenient. | 2298 * should only be called if this calendar is not lenient. |
2289 * @see #isLenient | 2299 * @see #isLenient |
2290 * @see #validateField(int, int&) | 2300 * @see #validateField(int, int&) |
2291 * @internal | 2301 * @internal |
2292 */ | 2302 */ |
2293 void validateFields(UErrorCode &status); | 2303 void validateFields(UErrorCode &status); |
2294 | 2304 |
2295 /** | 2305 /** |
2296 * Validate a single field of this calendar. Subclasses should | |
2297 * override this method to validate any calendar-specific fields. | |
2298 * Generic fields can be handled by | |
2299 * <code>Calendar::validateField()</code>. | |
2300 * @see #validateField(int, int, int, int&) | |
2301 * @internal | |
2302 */ | |
2303 virtual void validateField(UCalendarDateFields field, UErrorCode &status); | |
2304 | |
2305 /** | |
2306 * Validate a single field of this calendar given its minimum and | 2306 * Validate a single field of this calendar given its minimum and |
2307 * maximum allowed value. If the field is out of range, | 2307 * maximum allowed value. If the field is out of range, |
2308 * <code>U_ILLEGAL_ARGUMENT_ERROR</code> will be set. Subclasses may | 2308 * <code>U_ILLEGAL_ARGUMENT_ERROR</code> will be set. Subclasses may |
2309 * use this method in their implementation of {@link | 2309 * use this method in their implementation of {@link |
2310 * #validateField(int, int&)}. | 2310 * #validateField(int, int&)}. |
2311 * @internal | 2311 * @internal |
2312 */ | 2312 */ |
2313 void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErr
orCode& status); | 2313 void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErr
orCode& status); |
2314 | 2314 |
2315 protected: | 2315 protected: |
(...skipping 25 matching lines...) Expand all Loading... |
2341 * Return a StringEnumeration over the locales available at the time of the
call, | 2341 * Return a StringEnumeration over the locales available at the time of the
call, |
2342 * including registered locales. | 2342 * including registered locales. |
2343 * @return a StringEnumeration over the locales available at the time of the
call | 2343 * @return a StringEnumeration over the locales available at the time of the
call |
2344 * @internal | 2344 * @internal |
2345 */ | 2345 */ |
2346 static StringEnumeration* getAvailableLocales(void); | 2346 static StringEnumeration* getAvailableLocales(void); |
2347 | 2347 |
2348 /** | 2348 /** |
2349 * Register a new Calendar factory. The factory will be adopted. | 2349 * Register a new Calendar factory. The factory will be adopted. |
2350 * INTERNAL in 2.6 | 2350 * INTERNAL in 2.6 |
| 2351 * |
| 2352 * Because ICU may choose to cache Calendars internally, this must |
| 2353 * be called at application startup, prior to any calls to |
| 2354 * Calendar::createInstance to avoid undefined behavior. |
| 2355 * |
2351 * @param toAdopt the factory instance to be adopted | 2356 * @param toAdopt the factory instance to be adopted |
2352 * @param status the in/out status code, no special meanings are assigned | 2357 * @param status the in/out status code, no special meanings are assigned |
2353 * @return a registry key that can be used to unregister this factory | 2358 * @return a registry key that can be used to unregister this factory |
2354 * @internal | 2359 * @internal |
2355 */ | 2360 */ |
2356 static URegistryKey registerFactory(ICUServiceFactory* toAdopt, UErrorCode&
status); | 2361 static URegistryKey registerFactory(ICUServiceFactory* toAdopt, UErrorCode&
status); |
2357 | 2362 |
2358 /** | 2363 /** |
2359 * Unregister a previously-registered CalendarFactory using the key returned
from the | 2364 * Unregister a previously-registered CalendarFactory using the key returned
from the |
2360 * register call. Key becomes invalid after a successful call and should no
t be used again. | 2365 * register call. Key becomes invalid after a successful call and should no
t be used again. |
2361 * The CalendarFactory corresponding to the key will be deleted. | 2366 * The CalendarFactory corresponding to the key will be deleted. |
2362 * INTERNAL in 2.6 | 2367 * INTERNAL in 2.6 |
| 2368 * |
| 2369 * Because ICU may choose to cache Calendars internally, this should |
| 2370 * be called during application shutdown, after all calls to |
| 2371 * Calendar::createInstance to avoid undefined behavior. |
| 2372 * |
2363 * @param key the registry key returned by a previous call to registerFactor
y | 2373 * @param key the registry key returned by a previous call to registerFactor
y |
2364 * @param status the in/out status code, no special meanings are assigned | 2374 * @param status the in/out status code, no special meanings are assigned |
2365 * @return TRUE if the factory for the key was successfully unregistered | 2375 * @return TRUE if the factory for the key was successfully unregistered |
2366 * @internal | 2376 * @internal |
2367 */ | 2377 */ |
2368 static UBool unregister(URegistryKey key, UErrorCode& status); | 2378 static UBool unregister(URegistryKey key, UErrorCode& status); |
2369 #endif /* U_HIDE_INTERNAL_API */ | 2379 #endif /* U_HIDE_INTERNAL_API */ |
2370 | 2380 |
2371 /** | 2381 /** |
2372 * Multiple Calendar Implementation | 2382 * Multiple Calendar Implementation |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2405 virtual int32_t defaultCenturyStartYear() const = 0; | 2415 virtual int32_t defaultCenturyStartYear() const = 0; |
2406 | 2416 |
2407 /** Get the locale for this calendar object. You can choose between valid an
d actual locale. | 2417 /** Get the locale for this calendar object. You can choose between valid an
d actual locale. |
2408 * @param type type of the locale we're looking for (valid or actual) | 2418 * @param type type of the locale we're looking for (valid or actual) |
2409 * @param status error code for the operation | 2419 * @param status error code for the operation |
2410 * @return the locale | 2420 * @return the locale |
2411 * @stable ICU 2.8 | 2421 * @stable ICU 2.8 |
2412 */ | 2422 */ |
2413 Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const; | 2423 Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const; |
2414 | 2424 |
| 2425 /** |
| 2426 * @return The related Gregorian year; will be obtained by modifying th
e value |
| 2427 * obtained by get from UCAL_EXTENDED_YEAR field |
| 2428 * @internal |
| 2429 */ |
| 2430 virtual int32_t getRelatedYear(UErrorCode &status) const; |
| 2431 |
| 2432 /** |
| 2433 * @param year The related Gregorian year to set; will be modified as neces
sary then |
| 2434 * set in UCAL_EXTENDED_YEAR field |
| 2435 * @internal |
| 2436 */ |
| 2437 virtual void setRelatedYear(int32_t year); |
| 2438 |
2415 #ifndef U_HIDE_INTERNAL_API | 2439 #ifndef U_HIDE_INTERNAL_API |
2416 /** Get the locale for this calendar object. You can choose between valid an
d actual locale. | 2440 /** Get the locale for this calendar object. You can choose between valid an
d actual locale. |
2417 * @param type type of the locale we're looking for (valid or actual) | 2441 * @param type type of the locale we're looking for (valid or actual) |
2418 * @param status error code for the operation | 2442 * @param status error code for the operation |
2419 * @return the locale | 2443 * @return the locale |
2420 * @internal | 2444 * @internal |
2421 */ | 2445 */ |
2422 const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const; | 2446 const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const; |
2423 #endif /* U_HIDE_INTERNAL_API */ | 2447 #endif /* U_HIDE_INTERNAL_API */ |
2424 | 2448 |
2425 private: | 2449 private: |
2426 /** | 2450 /** |
2427 * Cast TimeZone used by this object to BasicTimeZone, or NULL if the TimeZo
ne | 2451 * Cast TimeZone used by this object to BasicTimeZone, or NULL if the TimeZo
ne |
2428 * is not an instance of BasicTimeZone. | 2452 * is not an instance of BasicTimeZone. |
2429 */ | 2453 */ |
2430 BasicTimeZone* getBasicTimeZone() const; | 2454 BasicTimeZone* getBasicTimeZone() const; |
| 2455 |
| 2456 /** |
| 2457 * Find the previous zone transtion near the given time. |
| 2458 * @param base The base time, inclusive |
| 2459 * @param transitionTime Receives the result time |
| 2460 * @param status The error status |
| 2461 * @return TRUE if a transition is found. |
| 2462 */ |
| 2463 UBool getImmediatePreviousZoneTransition(UDate base, UDate *transitionTime,
UErrorCode& status) const; |
2431 }; | 2464 }; |
2432 | 2465 |
2433 // ------------------------------------- | 2466 // ------------------------------------- |
2434 | 2467 |
2435 inline Calendar* | 2468 inline Calendar* |
2436 Calendar::createInstance(TimeZone* zone, UErrorCode& errorCode) | 2469 Calendar::createInstance(TimeZone* zone, UErrorCode& errorCode) |
2437 { | 2470 { |
2438 // since the Locale isn't specified, use the default locale | 2471 // since the Locale isn't specified, use the default locale |
2439 return createInstance(zone, Locale::getDefault(), errorCode); | 2472 return createInstance(zone, Locale::getDefault(), errorCode); |
2440 } | 2473 } |
2441 | 2474 |
2442 // ------------------------------------- | 2475 // ------------------------------------- |
2443 | 2476 |
2444 inline void | 2477 inline void |
2445 Calendar::roll(UCalendarDateFields field, UBool up, UErrorCode& status) | 2478 Calendar::roll(UCalendarDateFields field, UBool up, UErrorCode& status) |
2446 { | 2479 { |
2447 roll(field, (int32_t)(up ? +1 : -1), status); | 2480 roll(field, (int32_t)(up ? +1 : -1), status); |
2448 } | 2481 } |
2449 | 2482 |
2450 #ifndef U_HIDE_DEPRECATED_API | 2483 #ifndef U_HIDE_DEPRECATED_API |
2451 inline void | 2484 inline void |
2452 Calendar::roll(EDateFields field, UBool up, UErrorCode& status) | 2485 Calendar::roll(EDateFields field, UBool up, UErrorCode& status) |
2453 { | 2486 { |
2454 roll((UCalendarDateFields) field, up, status); | 2487 roll((UCalendarDateFields) field, up, status); |
2455 } | 2488 } |
2456 #endif | 2489 #endif /* U_HIDE_DEPRECATED_API */ |
2457 | 2490 |
2458 | 2491 |
2459 // ------------------------------------- | 2492 // ------------------------------------- |
2460 | 2493 |
2461 /** | 2494 /** |
2462 * Fast method for subclasses. The caller must maintain fUserSetDSTOffset and | 2495 * Fast method for subclasses. The caller must maintain fUserSetDSTOffset and |
2463 * fUserSetZoneOffset, as well as the isSet[] array. | 2496 * fUserSetZoneOffset, as well as the isSet[] array. |
2464 */ | 2497 */ |
2465 | 2498 |
2466 inline void | 2499 inline void |
2467 Calendar::internalSet(UCalendarDateFields field, int32_t value) | 2500 Calendar::internalSet(UCalendarDateFields field, int32_t value) |
2468 { | 2501 { |
2469 fFields[field] = value; | 2502 fFields[field] = value; |
2470 fStamp[field] = kInternallySet; | 2503 fStamp[field] = kInternallySet; |
2471 fIsSet[field] = TRUE; // Remove later | 2504 fIsSet[field] = TRUE; // Remove later |
2472 } | 2505 } |
2473 | 2506 |
2474 | 2507 |
2475 #ifndef U_HIDE_INTERNAL_API | 2508 #ifndef U_HIDE_INTERNAL_API |
2476 inline int32_t Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek) | 2509 inline int32_t Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek) |
2477 { | 2510 { |
2478 return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek); | 2511 return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek); |
2479 } | 2512 } |
2480 #endif | 2513 #endif /* U_HIDE_INTERNAL_API */ |
2481 | 2514 |
2482 U_NAMESPACE_END | 2515 U_NAMESPACE_END |
2483 | 2516 |
2484 #endif /* #if !UCONFIG_NO_FORMATTING */ | 2517 #endif /* #if !UCONFIG_NO_FORMATTING */ |
2485 | 2518 |
2486 #endif // _CALENDAR | 2519 #endif // _CALENDAR |
OLD | NEW |