X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/51004dcb01e06fef634b61be77ed73dd61cb6db9..38fbf2fd31f5cd99b500914d6037b1d06b608645:/icuSources/i18n/unicode/calendar.h diff --git a/icuSources/i18n/unicode/calendar.h b/icuSources/i18n/unicode/calendar.h index 6832939a..2beef715 100644 --- a/icuSources/i18n/unicode/calendar.h +++ b/icuSources/i18n/unicode/calendar.h @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************** -* Copyright (C) 1997-2013, International Business Machines +* Copyright (C) 1997-2014, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************** * @@ -39,6 +41,7 @@ #include "unicode/ucal.h" #include "unicode/umisc.h" +#if U_SHOW_CPLUSPLUS_API U_NAMESPACE_BEGIN class ICUServiceFactory; @@ -127,9 +130,9 @@ class BasicTimeZone; * *

* Ambiguous Wall Clock Time. When time offset from UTC has - * changed, it produces ambiguous time slot around the transition. For example, + * changed, it produces an ambiguous time slot around the transition. For example, * many US locations observe daylight saving time. On the date switching to daylight - * saving time in US, wall clock time jumps from 1:00 AM (standard) to 2:00 AM + * saving time in US, wall clock time jumps from 12:59 AM (standard) to 2:00 AM * (daylight). Therefore, wall clock time from 1:00 AM to 1:59 AM do not exist on * the date. When the input wall time fall into this missing time slot, the ICU * Calendar resolves the time using the UTC offset before the transition by default. @@ -1294,8 +1297,17 @@ public: /** * Clears the values of all the time fields, making them both unset and assigning - * them a value of zero. The field values will be determined during the next - * resolving of time into time fields. + * them a value of zero (except for era in some cases, see below). The field values + * will be determined during the next resolving of time into time fields. + * + * This effectively results in the following: + * 1. Gregorian-like calendars (gregorian, iso8601, japanese, buddhist, roc) are set + * to a UDate value of 0, corresponding to the epoch date of gregorian + * January 1, 1970 CE at UTC 00:00:00. + * 2. Other calendars are set to the beginning of the first day of the first month of + * the current era. Note that for the chinese and dangi calendars, the era + * corresponds to the current 60-year stem-branch cycle, so there is a new era + * every 60 years. The current era began on gregorian February 2, 1984. * @stable ICU 2.0 */ void clear(void); @@ -1708,11 +1720,21 @@ protected: * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case * where YEAR, EXTENDED_YEAR are not set. * The Calendar implementation assumes yearWoy is in extended gregorian form - * @internal * @return the extended year, UCAL_EXTENDED_YEAR + * @internal */ virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy); + /** + * Validate a single field of this calendar. Subclasses should + * override this method to validate any calendar-specific fields. + * Generic fields can be handled by + * Calendar::validateField(). + * @see #validateField(int, int, int, int&) + * @internal + */ + virtual void validateField(UCalendarDateFields field, UErrorCode &status); + #ifndef U_HIDE_INTERNAL_API /** * Compute the Julian day from fields. Will determine whether to use @@ -2154,7 +2176,7 @@ private: /** * Time zone affects the time calculation done by Calendar. Calendar subclasses use - * the time zone data to produce the local time. + * the time zone data to produce the local time. Always set; never NULL. */ TimeZone* fZone; @@ -2292,16 +2314,6 @@ private: */ void validateFields(UErrorCode &status); - /** - * Validate a single field of this calendar. Subclasses should - * override this method to validate any calendar-specific fields. - * Generic fields can be handled by - * Calendar::validateField(). - * @see #validateField(int, int, int, int&) - * @internal - */ - virtual void validateField(UCalendarDateFields field, UErrorCode &status); - /** * Validate a single field of this calendar given its minimum and * maximum allowed value. If the field is out of range, @@ -2348,6 +2360,11 @@ private: /** * Register a new Calendar factory. The factory will be adopted. * INTERNAL in 2.6 + * + * Because ICU may choose to cache Calendars internally, this must + * be called at application startup, prior to any calls to + * Calendar::createInstance to avoid undefined behavior. + * * @param toAdopt the factory instance to be adopted * @param status the in/out status code, no special meanings are assigned * @return a registry key that can be used to unregister this factory @@ -2360,6 +2377,11 @@ private: * register call. Key becomes invalid after a successful call and should not be used again. * The CalendarFactory corresponding to the key will be deleted. * INTERNAL in 2.6 + * + * Because ICU may choose to cache Calendars internally, this should + * be called during application shutdown, after all calls to + * Calendar::createInstance to avoid undefined behavior. + * * @param key the registry key returned by a previous call to registerFactory * @param status the in/out status code, no special meanings are assigned * @return TRUE if the factory for the key was successfully unregistered @@ -2388,19 +2410,19 @@ private: #endif /* !UCONFIG_NO_SERVICE */ /** - * @internal * @return TRUE if this calendar has a default century (i.e. 03 -> 2003) + * @internal */ virtual UBool haveDefaultCentury() const = 0; /** - * @internal * @return the start of the default century, as a UDate + * @internal */ virtual UDate defaultCenturyStart() const = 0; /** - * @internal * @return the beginning year of the default century, as a year + * @internal */ virtual int32_t defaultCenturyStartYear() const = 0; @@ -2412,6 +2434,20 @@ private: */ Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const; + /** + * @return The related Gregorian year; will be obtained by modifying the value + * obtained by get from UCAL_EXTENDED_YEAR field + * @internal + */ + virtual int32_t getRelatedYear(UErrorCode &status) const; + + /** + * @param year The related Gregorian year to set; will be modified as necessary then + * set in UCAL_EXTENDED_YEAR field + * @internal + */ + virtual void setRelatedYear(int32_t year); + #ifndef U_HIDE_INTERNAL_API /** Get the locale for this calendar object. You can choose between valid and actual locale. * @param type type of the locale we're looking for (valid or actual) @@ -2428,6 +2464,45 @@ private: * is not an instance of BasicTimeZone. */ BasicTimeZone* getBasicTimeZone() const; + + /** + * Find the previous zone transtion near the given time. + * @param base The base time, inclusive + * @param transitionTime Receives the result time + * @param status The error status + * @return TRUE if a transition is found. + */ + UBool getImmediatePreviousZoneTransition(UDate base, UDate *transitionTime, UErrorCode& status) const; + +public: +#ifndef U_HIDE_INTERNAL_API + /** + * Creates a new Calendar from a Locale for the cache. + * This method does not set the time or timezone in returned calendar. + * @param locale the locale. + * @param status any error returned here. + * @return the new Calendar object with no time or timezone set. + * @internal For ICU use only. + */ + static Calendar * U_EXPORT2 makeInstance( + const Locale &locale, UErrorCode &status); + + /** + * Get the calendar type for given locale. + * @param locale the locale + * @param typeBuffer calendar type returned here + * @param typeBufferSize The size of typeBuffer in bytes. If the type + * can't fit in the buffer, this method sets status to + * U_BUFFER_OVERFLOW_ERROR + * @param status error, if any, returned here. + * @internal For ICU use only. + */ + static void U_EXPORT2 getCalendarTypeFromLocale( + const Locale &locale, + char *typeBuffer, + int32_t typeBufferSize, + UErrorCode &status); +#endif /* U_HIDE_INTERNAL_API */ }; // ------------------------------------- @@ -2453,7 +2528,7 @@ Calendar::roll(EDateFields field, UBool up, UErrorCode& status) { roll((UCalendarDateFields) field, up, status); } -#endif +#endif /* U_HIDE_DEPRECATED_API */ // ------------------------------------- @@ -2477,9 +2552,10 @@ inline int32_t Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek) { return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek); } -#endif +#endif /* U_HIDE_INTERNAL_API */ U_NAMESPACE_END +#endif // U_SHOW_CPLUSPLUS_API #endif /* #if !UCONFIG_NO_FORMATTING */