X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..a01113dcd0f39d5da295ef82785beff9ed86fe38:/icuSources/i18n/gregoimp.h diff --git a/icuSources/i18n/gregoimp.h b/icuSources/i18n/gregoimp.h index f65d1410..06eb3238 100644 --- a/icuSources/i18n/gregoimp.h +++ b/icuSources/i18n/gregoimp.h @@ -1,3 +1,5 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** * Copyright (c) 2003-2008, International Business Machines @@ -38,6 +40,17 @@ class ClockMath { */ static int32_t floorDivide(int32_t numerator, int32_t denominator); + /** + * Divide two integers, returning the floor of the quotient. + * Unlike the built-in division, this is mathematically + * well-behaved. E.g., -1/4 => 0 but + * floorDivide(-1,4) => -1. + * @param numerator the numerator + * @param denominator a divisor which must be != 0 + * @return the floor of the quotient + */ + static int64_t floorDivide(int64_t numerator, int64_t denominator); + /** * Divide two numbers, returning the floor of the quotient. * Unlike the built-in division, this is mathematically @@ -286,76 +299,11 @@ inline int32_t Grego::millisToJulianDay(double millis) { } inline int32_t Grego::gregorianShift(int32_t eyear) { - int32_t y = eyear-1; - int32_t gregShift = ClockMath::floorDivide(y, 400) - ClockMath::floorDivide(y, 100) + 2; + int64_t y = (int64_t)eyear-1; + int32_t gregShift = static_cast(ClockMath::floorDivide(y, (int64_t)400) - ClockMath::floorDivide(y, (int64_t)100) + 2); return gregShift; } -/** - * This utility class provides convenient access to the data needed for a calendar. - * @internal ICU 3.0 - */ -class CalendarData : public UMemory { -public: - /** - * Construct a CalendarData from the given locale. - * @param loc locale to use. The 'calendar' keyword will be ignored. - * @param type calendar type. NULL indicates the gregorian calendar. - * No default lookup is done. - * @param status error code - */ - CalendarData(const Locale& loc, const char *type, UErrorCode& status); - - /** - * Load data for calendar. Note, this object owns the resources, do NOT call ures_close()! - * The ResourceBundle C++ API should NOT be used because it is too slow for a low level API. - * - * @param key Resource key to data - * @param status Error Status - * @internal - */ - UResourceBundle* getByKey(const char *key, UErrorCode& status); - - /** - * Load data for calendar. Note, this object owns the resources, do NOT call ures_close()! - * There is an implicit key of 'format' - * data is located in: "calendar/key/format/subKey" - * for example, calendar/dayNames/format/abbreviated - * The ResourceBundle C++ API should NOT be used because it is too slow for a low level API. - * - * @param key Resource key to data - * @param subKey Resource key to data - * @param status Error Status - * @internal - */ - UResourceBundle* getByKey2(const char *key, const char *subKey, UErrorCode& status); - - /** - * Load data for calendar. Note, this object owns the resources, do NOT call ures_close()! - * data is located in: "calendar/key/contextKey/subKey" - * for example, calendar/dayNames/standalone/narrow - * The ResourceBundle C++ API should NOT be used because it is too slow for a low level API. - * - * @param key Resource key to data - * @param contextKey Resource key to data - * @param subKey Resource key to data - * @param status Error Status - * @internal - */ - UResourceBundle* getByKey3(const char *key, const char *contextKey, const char *subKey, UErrorCode& status); - - ~CalendarData(); - -private: - void initData(const char *locale, const char *type, UErrorCode& status); - - UResourceBundle *fFillin; - UResourceBundle *fOtherFillin; - UResourceBundle *fBundle; - UResourceBundle *fFallback; - CalendarData(); // Not implemented. -}; - U_NAMESPACE_END #endif // !UCONFIG_NO_FORMATTING