mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-2943 incorporate changes from the review meeting, clean up docs
X-SVN-Rev: 13681
This commit is contained in:
parent
4b35b705b1
commit
9924fd34a7
7 changed files with 355 additions and 185 deletions
|
@ -92,10 +92,7 @@ public:
|
|||
*/
|
||||
virtual Calendar* clone(void) const;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
|
||||
* override. This method is to implement a simple version of RTTI, since not all C++
|
||||
|
@ -144,13 +141,36 @@ public:
|
|||
virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* API overrides
|
||||
* @private
|
||||
* Gets the maximum value for the given time field. e.g. for DAY_OF_MONTH,
|
||||
* 31.
|
||||
*
|
||||
* @param field The given time field.
|
||||
* @return The maximum value for the given time field.
|
||||
* @draft ICU 2.6.
|
||||
*/
|
||||
int32_t getMaximum(UCalendarDateFields field) const;
|
||||
|
||||
/**
|
||||
* Gets the lowest maximum value for the given field if varies. Otherwise same as
|
||||
* getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
|
||||
*
|
||||
* @param field The given time field.
|
||||
* @return The lowest maximum value for the given time field.
|
||||
* @draft ICU 2.6.
|
||||
*/
|
||||
int32_t getLeastMaximum(UCalendarDateFields field) const;
|
||||
|
||||
/**
|
||||
* @deprecated ICU 2.6 use UCalendarDateFields instead of EDateFields
|
||||
*/
|
||||
inline virtual int32_t getMaximum(EDateFields field) const { return getMaximum((UCalendarDateFields)field); }
|
||||
/**
|
||||
* @deprecated ICU 2.6 use UCalendarDateFields instead of EDateFields
|
||||
*/
|
||||
inline virtual int32_t getLeastMaximum(EDateFields field) const { return getLeastMaximum((UCalendarDateFields)field); }
|
||||
/**
|
||||
* @deprecated ICU 2.6 use UCalendarDateFields instead of EDateFields
|
||||
*/
|
||||
inline virtual void add(EDateFields field, int32_t amount, UErrorCode& status) { add((UCalendarDateFields)field, amount, status); }
|
||||
|
||||
private:
|
||||
|
@ -159,21 +179,85 @@ private:
|
|||
static const char fgClassID;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Return the extended year defined by the current fields. This will
|
||||
* use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
|
||||
* as UCAL_ERA) specific to the calendar system, depending on which set of
|
||||
* fields is newer.
|
||||
* @return the extended year
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t handleGetExtendedYear();
|
||||
/**
|
||||
* Subclasses may override this method to compute several fields
|
||||
* specific to each calendar system.
|
||||
* @internal
|
||||
*/
|
||||
virtual void handleComputeFields(int32_t julianDay, UErrorCode& status);
|
||||
/**
|
||||
* Subclass API for defining limits of different types.
|
||||
* @param field one of the field numbers
|
||||
* @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
|
||||
* <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
|
||||
/**
|
||||
* Return the Julian day number of day before the first day of the
|
||||
* given month in the given extended year. Subclasses should override
|
||||
* this method to implement their calendar system.
|
||||
* @param eyear the extended year
|
||||
* @param month the zero-based month, or 0 if useMonth is false
|
||||
* @param useMonth if false, compute the day before the first day of
|
||||
* the given year, otherwise, compute the day before the first day of
|
||||
* the given month
|
||||
* @param return the Julian day number of the day before the first
|
||||
* day of the given month and year
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
|
||||
UBool useMonth) const;
|
||||
|
||||
|
||||
// older internals below
|
||||
/**
|
||||
* month length of current month
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t monthLength(int32_t month) const;
|
||||
/**
|
||||
* month length of month
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t monthLength(int32_t month, int32_t year) const;
|
||||
|
||||
/**
|
||||
* month length of current month
|
||||
* @internal
|
||||
*/
|
||||
int32_t getGregorianYear(UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Calculate the era for internal computation
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t internalGetEra() const;
|
||||
|
||||
/**
|
||||
* Returns TRUE because the Buddhist Calendar does have a default century
|
||||
* @internal
|
||||
*/
|
||||
virtual UBool haveDefaultCentury() const;
|
||||
|
||||
/**
|
||||
* Returns the date of the start of the default century
|
||||
* @return start of century - in milliseconds since epoch, 1970
|
||||
* @internal
|
||||
*/
|
||||
virtual UDate defaultCenturyStart() const;
|
||||
|
||||
/**
|
||||
* Returns the year in which the default century begins
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t defaultCenturyStartYear() const;
|
||||
|
||||
private: // default century stuff.
|
||||
|
@ -195,27 +279,27 @@ private:
|
|||
*/
|
||||
static const int32_t fgSystemDefaultCenturyYear;
|
||||
|
||||
/**
|
||||
* start of default century, as a date
|
||||
*/
|
||||
static const UDate fgSystemDefaultCentury;
|
||||
|
||||
/**
|
||||
* Returns the beginning date of the 100-year window that dates with 2-digit years
|
||||
* are considered to fall within.
|
||||
* @return the beginning date of the 100-year window that dates with 2-digit years
|
||||
* are considered to fall within.
|
||||
* Returns the beginning date of the 100-year window that dates
|
||||
* with 2-digit years are considered to fall within.
|
||||
*/
|
||||
UDate internalGetDefaultCenturyStart(void) const;
|
||||
|
||||
/**
|
||||
* Returns the first year of the 100-year window that dates with 2-digit years
|
||||
* are considered to fall within.
|
||||
* @return the first year of the 100-year window that dates with 2-digit years
|
||||
* are considered to fall within.
|
||||
* Returns the first year of the 100-year window that dates with
|
||||
* 2-digit years are considered to fall within.
|
||||
*/
|
||||
int32_t internalGetDefaultCenturyStartYear(void) const;
|
||||
|
||||
/**
|
||||
* Initializes the 100-year window that dates with 2-digit years are considered
|
||||
* to fall within so that its start date is 80 years before the current time.
|
||||
* Initializes the 100-year window that dates with 2-digit years
|
||||
* are considered to fall within so that its start date is 80 years
|
||||
* before the current time.
|
||||
*/
|
||||
static void initializeSystemDefaultCentury(void);
|
||||
};
|
||||
|
|
|
@ -2670,8 +2670,8 @@ Calendar::getActualMaximum(UCalendarDateFields field, UErrorCode& status) const
|
|||
case ZONE_OFFSET:
|
||||
case DST_OFFSET:
|
||||
case DOW_LOCAL:
|
||||
case JULIAN_DAY:
|
||||
case MILLISECONDS_IN_DAY:
|
||||
case UCAL_JULIAN_DAY:
|
||||
case UCAL_MILLISECONDS_IN_DAY:
|
||||
// These fields all have fixed minima/maxima
|
||||
result = getMaximum(field);
|
||||
break;
|
||||
|
|
|
@ -621,35 +621,6 @@ GregorianCalendar::yearLength() const
|
|||
|
||||
// -------------------------------------
|
||||
|
||||
/**
|
||||
* Overrides Calendar
|
||||
* corrects for Gregorian shift
|
||||
* @see Calendar#complete
|
||||
*/
|
||||
void
|
||||
GregorianCalendar::computeFields(UErrorCode& ec) {
|
||||
Calendar::computeFields(ec);
|
||||
|
||||
if (U_FAILURE(ec)) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* compensate for gregorian cutover */
|
||||
if((internalGet(UCAL_EXTENDED_YEAR) == fGregorianCutoverYear) &&
|
||||
fFields[UCAL_JULIAN_DAY] >= fCutoverJulianDay) {
|
||||
#if defined (U_DEBUG_CAL)
|
||||
fprintf(stderr, "%s:%d: cf - gregorian cutover issue!\n",
|
||||
__FILE__, __LINE__);
|
||||
#endif
|
||||
fFields[UCAL_DAY_OF_YEAR] -= kGregorianShift;
|
||||
fFields[UCAL_WEEK_OF_YEAR] -= kGregorianWeekShift;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
/**
|
||||
* After adjustments such as add(MONTH), add(YEAR), we don't want the
|
||||
* month to jump around. E.g., we don't want Jan 31 + 1 month to go to Mar
|
||||
|
@ -1069,24 +1040,24 @@ GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& s
|
|||
|
||||
|
||||
/**
|
||||
* Return the minimum value that this field could have, given the current date.
|
||||
* For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
|
||||
* @param field the time field.
|
||||
* @return the minimum value that this field could have, given the current date.
|
||||
* @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead.
|
||||
*/
|
||||
* Return the minimum value that this field could have, given the current date.
|
||||
* For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
|
||||
* @param field the time field.
|
||||
* @return the minimum value that this field could have, given the current date.
|
||||
* @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead.
|
||||
*/
|
||||
int32_t GregorianCalendar::getActualMinimum(EDateFields field) const
|
||||
{
|
||||
return getMinimum((UCalendarDateFields)field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minimum value that this field could have, given the current date.
|
||||
* For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
|
||||
* @param field the time field.
|
||||
* @return the minimum value that this field could have, given the current date.
|
||||
* @draft ICU 2.6.
|
||||
*/
|
||||
* Return the minimum value that this field could have, given the current date.
|
||||
* For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
|
||||
* @param field the time field.
|
||||
* @return the minimum value that this field could have, given the current date.
|
||||
* @draft ICU 2.6.
|
||||
*/
|
||||
int32_t GregorianCalendar::getActualMinimum(UCalendarDateFields field) const
|
||||
{
|
||||
return getMinimum(field);
|
||||
|
|
|
@ -99,10 +99,14 @@ public:
|
|||
*/
|
||||
virtual Calendar* clone(void) const;
|
||||
|
||||
/**
|
||||
* Return the extended year defined by the current fields. In the
|
||||
* Japanese calendar case, this is equal to the equivalent extended Gregorian year.
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t handleGetExtendedYear();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
|
||||
* override. This method is to implement a simple version of RTTI, since not all C++
|
||||
|
@ -137,11 +141,20 @@ public:
|
|||
virtual const char * getType() const;
|
||||
|
||||
/**
|
||||
* @return FALSE - no default century in Japanese
|
||||
* @internal
|
||||
* @return TRUE if this calendar has the notion of a default century
|
||||
*/
|
||||
virtual UBool haveDefaultCentury() const;
|
||||
|
||||
/**
|
||||
* Not used - no default century.
|
||||
* @internal
|
||||
*/
|
||||
virtual UDate defaultCenturyStart() const;
|
||||
/**
|
||||
* Not used - no default century.
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t defaultCenturyStartYear() const;
|
||||
|
||||
private:
|
||||
|
@ -150,38 +163,39 @@ private:
|
|||
static const char fgClassID;
|
||||
|
||||
protected:
|
||||
//virtual int32_t monthLength(int32_t month) const;
|
||||
//virtual int32_t monthLength(int32_t month, int32_t year) const;
|
||||
// int32_t getGregorianYear(UErrorCode& status) const;
|
||||
/**
|
||||
* Calculate the era for internal computation
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t internalGetEra() const;
|
||||
virtual void handleComputeFields(int32_t julianDay, UErrorCode& status);
|
||||
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) Converts Calendar's time field values to GMT as
|
||||
* milliseconds. In this case, we have to be concerned with filling in inconsistent
|
||||
* information. For example, if the year and era only are set, need to make sure
|
||||
* month & date are set correctly. Ex, 'Heisei 1' starts Jan 8th, not Jan 1st.
|
||||
* Default month and date values will end up giving the wrong Era.
|
||||
*
|
||||
* @param status Output param set to success/failure code on exit. If any value
|
||||
* previously set in the time field is invalid, this will be set to
|
||||
* an error status.
|
||||
* @stable ICU 2.0
|
||||
* Compute fields from the JD
|
||||
* @internal
|
||||
*/
|
||||
virtual void handleComputeFields(int32_t julianDay, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Calculate the limit for a specified type of limit and field
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
|
||||
|
||||
/***
|
||||
* Called by computeJulianDay. Returns the default month (0-based) for the year,
|
||||
* taking year and era into account. Defaults to 0 for Gregorian, which doesn't care.
|
||||
* taking year and era into account. Will return the first month of the given era, if
|
||||
* the current year is an ascension year.
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t getDefaultMonthInYear() ;
|
||||
|
||||
virtual int32_t getDefaultMonthInYear();
|
||||
|
||||
/***
|
||||
* Called by computeJulianDay. Returns the default day (1-based) for the month,
|
||||
* taking currently-set year and era into account. Defaults to 1 for Gregorian, which doesn't care.
|
||||
* taking currently-set year and era into account. Will return the first day of the given
|
||||
* era, if the current month is an ascension year and month.
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t getDefaultDayInMonth(int32_t month) ;
|
||||
virtual int32_t getDefaultDayInMonth(int32_t month);
|
||||
};
|
||||
|
||||
inline UClassID
|
||||
|
@ -197,6 +211,6 @@ U_NAMESPACE_END
|
|||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // _GREGOCAL
|
||||
#endif
|
||||
//eof
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* 11/15/99 weiv added YEAR_WOY and DOW_LOCAL
|
||||
* to EDateFields
|
||||
* 8/19/2002 srl Removed Javaisms
|
||||
* 11/07/2003 srl Update, clean up documentation.
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
|
@ -188,17 +189,10 @@ public:
|
|||
MILLISECOND, // Example: 0..999
|
||||
ZONE_OFFSET, // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR
|
||||
DST_OFFSET, // Example: 0 or U_MILLIS_PER_HOUR
|
||||
// here will go names for 'Y' and 'e'
|
||||
YEAR_WOY, // 'Y' Example: 1..big number
|
||||
DOW_LOCAL, // 'e' Example: 1..7
|
||||
|
||||
EXTENDED_YEAR, // Year of this calendar system, encompassing all supra-year fields. For example, in Gregorian/Julian calendars, positive Extended Year values indicate years AD, 1 BC = -1 extended, 2 BC = -2 extended, and so on.
|
||||
JULIAN_DAY, // Modified Julian day number, encompassing all date-related fields. Demarcates at local midnight.
|
||||
MILLISECONDS_IN_DAY, // Ranges from 0 to 23:59:59.999 (regardless of DST). This field behaves <em>exactly</em> like a composite of all time-related fields, not including the zone fields. As such, it also reflects discontinuities of those fields on DST transition days. On a day of DST onset, it will jump forward. On a day of DST cessation, it will jump backward. This reflects the fact that is must be combined with the DST_OFFSET field to obtain a unique local time value.
|
||||
|
||||
FIELD_COUNT,
|
||||
YEAR_WOY, // 'Y' Example: 1..big number - Year of Week of Year
|
||||
DOW_LOCAL, // 'e' Example: 1..7 - Day of Week / Localized
|
||||
|
||||
DAY_OF_MONTH = DATE // Synonyms
|
||||
FIELD_COUNT = UCAL_FIELD_COUNT
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1325,7 +1319,17 @@ protected:
|
|||
*/
|
||||
virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status);
|
||||
|
||||
enum ELimitType { U_CAL_LIMIT_MINIMUM = 0, U_CAL_LIMIT_GREATEST_MINIMUM, U_CAL_LIMIT_LEAST_MAXIMUM, U_CAL_LIMIT_MAXIMUM, U_CAL_LIMIT_COUNT };
|
||||
/**
|
||||
* Limit enums. Not in sync with UCalendarLimitTypes
|
||||
* @internal
|
||||
*/
|
||||
enum ELimitType {
|
||||
U_CAL_LIMIT_MINIMUM = 0,
|
||||
U_CAL_LIMIT_GREATEST_MINIMUM,
|
||||
U_CAL_LIMIT_LEAST_MAXIMUM,
|
||||
U_CAL_LIMIT_MAXIMUM,
|
||||
U_CAL_LIMIT_COUNT
|
||||
};
|
||||
|
||||
/**
|
||||
* Subclass API for defining limits of different types.
|
||||
|
@ -1409,6 +1413,8 @@ protected:
|
|||
* Subclasses may override this. This method calls
|
||||
* handleGetMonthLength() to obtain the calendar-specific month
|
||||
* length.
|
||||
* @param bestField which field to use to calculate the date
|
||||
* @return julian day specified by calendar fields.
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField);
|
||||
|
@ -1423,6 +1429,12 @@ protected:
|
|||
*/
|
||||
virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
|
||||
|
||||
/**
|
||||
* Compute the Julian day from fields. Will determine whether to use
|
||||
* the JULIAN_DAY field directly, or other fields.
|
||||
* @return the julian day
|
||||
* @internal
|
||||
*/
|
||||
int32_t computeJulianDay();
|
||||
|
||||
/**
|
||||
|
@ -1445,25 +1457,41 @@ protected:
|
|||
|
||||
|
||||
/**
|
||||
* Return the best stamp in a range.
|
||||
* Determine the best stamp in a range.
|
||||
* @param start first enum to look at
|
||||
* @param end last enum to look at
|
||||
* @param best stamp prior to function call
|
||||
* @return the stamp value of the best stamp
|
||||
* @internal
|
||||
*/
|
||||
int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const;
|
||||
|
||||
/**
|
||||
* Value to OR against resolve table field values for remapping.
|
||||
* Value to be bitwised "ORed" against resolve table field values for remapping.
|
||||
* @see #resolveFields
|
||||
* @internal
|
||||
*/
|
||||
static const int32_t kResolveRemap;
|
||||
|
||||
/**
|
||||
* Type for resolution tables
|
||||
* Precedence table for Dates
|
||||
* @see #resolveFields
|
||||
* @internal
|
||||
*/
|
||||
static const UFieldResolutionTable kDatePrecedence[];
|
||||
|
||||
/**
|
||||
* Precedence table for Year
|
||||
* @see #resolveFields
|
||||
* @internal
|
||||
*/
|
||||
static const UFieldResolutionTable kYearPrecedence[];
|
||||
|
||||
/**
|
||||
* Precedence table for Day of Week
|
||||
* @see #resolveFields
|
||||
* @internal
|
||||
*/
|
||||
static const UFieldResolutionTable kDOWPrecedence[];
|
||||
|
||||
/**
|
||||
|
@ -1506,6 +1534,14 @@ protected:
|
|||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Helper function for calculating limits by trial and error
|
||||
* @param field The field being investigated
|
||||
* @param startValue starting (least max) value of field
|
||||
* @param endValue ending (greatest max) value of field
|
||||
* @param status return type
|
||||
* @internal
|
||||
*/
|
||||
int32_t getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const;
|
||||
|
||||
|
||||
|
@ -1611,6 +1647,7 @@ protected:
|
|||
* Return the extended year on the Gregorian calendar as computed by
|
||||
* <code>computeGregorianFields()</code>.
|
||||
* @see #computeGregorianFields
|
||||
* @internal
|
||||
*/
|
||||
int32_t getGregorianYear() const {
|
||||
return fGregorianYear;
|
||||
|
@ -1620,6 +1657,7 @@ protected:
|
|||
* Return the month (0-based) on the Gregorian calendar as computed by
|
||||
* <code>computeGregorianFields()</code>.
|
||||
* @see #computeGregorianFields
|
||||
* @internal
|
||||
*/
|
||||
int32_t getGregorianMonth() const {
|
||||
return fGregorianMonth;
|
||||
|
@ -1629,6 +1667,7 @@ protected:
|
|||
* Return the day of year (1-based) on the Gregorian calendar as
|
||||
* computed by <code>computeGregorianFields()</code>.
|
||||
* @see #computeGregorianFields
|
||||
* @internal
|
||||
*/
|
||||
int32_t getGregorianDayOfYear() const {
|
||||
return fGregorianDayOfYear;
|
||||
|
@ -1638,6 +1677,7 @@ protected:
|
|||
* Return the day of month (1-based) on the Gregorian calendar as
|
||||
* computed by <code>computeGregorianFields()</code>.
|
||||
* @see #computeGregorianFields
|
||||
* @internal
|
||||
*/
|
||||
int32_t getGregorianDayOfMonth() const {
|
||||
return fGregorianDayOfMonth;
|
||||
|
@ -1647,13 +1687,14 @@ protected:
|
|||
* Called by computeJulianDay. Returns the default month (0-based) for the year,
|
||||
* taking year and era into account. Defaults to 0 for Gregorian, which doesn't care.
|
||||
* @internal
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t getDefaultMonthInYear() ;
|
||||
|
||||
|
||||
/**
|
||||
* Called by computeJulianDay. Returns the default day (1-based) for the month,
|
||||
* taking currently-set year and era into account. Defaults to 1 for Gregorian, which doesn't care.
|
||||
* taking currently-set year and era into account. Defaults to 1 for Gregorian.
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t getDefaultDayInMonth(int32_t /*month*/);
|
||||
|
@ -1764,17 +1805,21 @@ protected:
|
|||
* the first week because
|
||||
* {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}
|
||||
* is more than one.
|
||||
* @internal
|
||||
*/
|
||||
inline int32_t weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek);
|
||||
|
||||
/**
|
||||
* returns the local DOW, valid range 0..6
|
||||
* @internal
|
||||
*/
|
||||
int32_t getLocalDOW();
|
||||
|
||||
private:
|
||||
|
||||
// The next available value for stampp[]
|
||||
/**
|
||||
* The next available value for fStamp[]
|
||||
*/
|
||||
int32_t fNextStamp;// = MINIMUM_USER_STAMP;
|
||||
|
||||
/**
|
||||
|
@ -1945,6 +1990,7 @@ private:
|
|||
*
|
||||
* @param julian The given Julian date number.
|
||||
* @return Day number from 1..7 (SUN..SAT).
|
||||
* @internal
|
||||
*/
|
||||
static uint8_t julianDayToDayOfWeek(double julian);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* Added documentation of WEEK_OF_YEAR computation.
|
||||
* 10/15/99 aliu Fixed j32, cannot set date to Feb 29 2000 AD.
|
||||
* {JDK bug 4210209 4209272}
|
||||
* 11/07/2003 srl Update, clean up documentation.
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
|
@ -341,34 +342,6 @@ public:
|
|||
*/
|
||||
virtual UBool isEquivalentTo(const Calendar& other) const;
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) UDate Arithmetic function. Adds the specified (signed) amount
|
||||
* of time to the given time field, based on the calendar's rules. For more
|
||||
* information, see the documentation for Calendar::add().
|
||||
*
|
||||
* @param field The time field.
|
||||
* @param amount The amount of date or time to be added to the field.
|
||||
* @param status Output param set to success/failure code on exit. If any value
|
||||
* previously set in the time field is invalid, this will be set to
|
||||
* an error status.
|
||||
* @deprecated ICU 2.6. Use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
|
||||
*/
|
||||
// virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) UDate Arithmetic function. Adds the specified (signed) amount
|
||||
* of time to the given time field, based on the calendar's rules. For more
|
||||
* information, see the documentation for Calendar::add().
|
||||
*
|
||||
* @param field The time field.
|
||||
* @param amount The amount of date or time to be added to the field.
|
||||
* @param status Output param set to success/failure code on exit. If any value
|
||||
* previously set in the time field is invalid, this will be set to
|
||||
* an error status.
|
||||
* @draft ICU 2.6.
|
||||
*/
|
||||
// virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) Rolls up or down by the given amount in the specified field.
|
||||
* For more information, see the documentation for Calendar::roll().
|
||||
|
@ -395,7 +368,6 @@ public:
|
|||
*/
|
||||
virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
|
||||
|
||||
|
||||
/**
|
||||
* Return the minimum value that this field could have, given the current date.
|
||||
* For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
|
||||
|
@ -432,14 +404,9 @@ public:
|
|||
* for some years the actual maximum for MONTH is 12, and for others 13.
|
||||
* @param field the time field.
|
||||
* @return the maximum value that this field could have, given the current date.
|
||||
* @internal.
|
||||
*/
|
||||
virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
|
||||
|
||||
/*
|
||||
* @draft ICU 2.6
|
||||
*/
|
||||
inline int32_t getActualMaximum(UCalendarDateFields field) const;
|
||||
virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) Return true if the current date for this Calendar is in
|
||||
|
@ -523,10 +490,15 @@ protected:
|
|||
virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
|
||||
UBool useMonth) const;
|
||||
|
||||
/**
|
||||
* Subclasses may override this. This method calls
|
||||
* handleGetMonthLength() to obtain the calendar-specific month
|
||||
* length.
|
||||
* @param bestField which field to use to calculate the date
|
||||
* @return julian day specified by calendar fields.
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField) ;
|
||||
virtual void computeFields(UErrorCode& ec);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of days in the given month of the given extended
|
||||
|
@ -537,6 +509,13 @@ protected:
|
|||
*/
|
||||
virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const;
|
||||
|
||||
/**
|
||||
* Return the number of days in the given extended year of this
|
||||
* calendar system. Subclasses should override this method if they can
|
||||
* provide a more correct or more efficient implementation than the
|
||||
* default implementation in Calendar.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t handleGetYearLength(int32_t eyear) const;
|
||||
|
||||
/**
|
||||
|
@ -589,19 +568,6 @@ protected:
|
|||
*/
|
||||
virtual UDate getEpochDay(UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Compute the date-based fields given the milliseconds since the epoch start. Do
|
||||
* not compute the time-based fields (HOUR, MINUTE, etc.).
|
||||
*
|
||||
* @param theTime the time in wall millis (either Standard or DST),
|
||||
* whichever is in effect
|
||||
* @param quick if true, only compute the ERA, YEAR, MONTH, DATE,
|
||||
* DAY_OF_WEEK, and DAY_OF_YEAR.
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @internal
|
||||
*/
|
||||
// virtual void timeToFields(UDate theTime, UBool quick, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Subclass API for defining limits of different types.
|
||||
* Subclasses must implement this method to return limits for the
|
||||
|
@ -625,6 +591,14 @@ protected:
|
|||
*/
|
||||
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
|
||||
|
||||
/**
|
||||
* Return the extended year defined by the current fields. This will
|
||||
* use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
|
||||
* as UCAL_ERA) specific to the calendar system, depending on which set of
|
||||
* fields is newer.
|
||||
* @return the extended year
|
||||
* @internal
|
||||
*/
|
||||
virtual int32_t handleGetExtendedYear();
|
||||
|
||||
/**
|
||||
|
@ -637,6 +611,21 @@ protected:
|
|||
virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
|
||||
|
||||
|
||||
/**
|
||||
* Subclasses may override this method to compute several fields
|
||||
* specific to each calendar system. These are:
|
||||
*
|
||||
* <ul><li>ERA
|
||||
* <li>YEAR
|
||||
* <li>MONTH
|
||||
* <li>DAY_OF_MONTH
|
||||
* <li>DAY_OF_YEAR
|
||||
* <li>EXTENDED_YEAR</ul>
|
||||
*
|
||||
* <p>The GregorianCalendar implementation implements
|
||||
* a calendar with the specified Julian/Gregorian cutover date.
|
||||
* @internal
|
||||
*/
|
||||
virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
|
||||
|
||||
private:
|
||||
|
@ -677,9 +666,9 @@ protected:
|
|||
* milliseconds from the standard epoch. Default is October 15, 1582
|
||||
* (Gregorian) 00:00:00 UTC, that is, October 4, 1582 (Julian) is followed
|
||||
* by October 15, 1582 (Gregorian). This corresponds to Julian day number
|
||||
* 2299161.
|
||||
* 2299161. This is measured from the standard epoch, not in Julian Days.
|
||||
* @internal
|
||||
*/
|
||||
// This is measured from the standard epoch, not in Julian Days.
|
||||
UDate fGregorianCutover;
|
||||
|
||||
/**
|
||||
|
@ -726,16 +715,18 @@ protected:
|
|||
|
||||
/**
|
||||
* Used by handleComputeJulianDay() and handleComputeMonthStart().
|
||||
* Temporary field indicating whether the calendar is currently Gregorian as opposed to Julian.
|
||||
*/
|
||||
UBool fIsGregorian;
|
||||
|
||||
/**
|
||||
* Used by handleComputeJulianDay() and handleComputeMonthStart().
|
||||
* Temporary field indicating that the sense of the gregorian cutover should be inverted
|
||||
* to handle certain calculations on and around the cutover date.
|
||||
*/
|
||||
UBool fInvertGregorian;
|
||||
|
||||
|
||||
|
||||
public: // internal implementation
|
||||
|
||||
/**
|
||||
|
@ -804,14 +795,6 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
|
||||
inline int32_t GregorianCalendar::getActualMaximum(UCalendarDateFields field) const
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
return getActualMaximum(field, status);
|
||||
}
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
|
|
@ -159,54 +159,126 @@ typedef enum UCalendarType UCalendarType;
|
|||
* @stable ICU 2.0
|
||||
*/
|
||||
enum UCalendarDateFields {
|
||||
/** Era field */
|
||||
/**
|
||||
* Era field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_ERA,
|
||||
/** Year field */
|
||||
/**
|
||||
* Year field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_YEAR,
|
||||
/** Month field */
|
||||
/**
|
||||
* Month field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_MONTH,
|
||||
/** Week of year field */
|
||||
/**
|
||||
* Week of year field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_WEEK_OF_YEAR,
|
||||
/** Week of month field */
|
||||
/**
|
||||
* Week of month field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_WEEK_OF_MONTH,
|
||||
/** Date field */
|
||||
/**
|
||||
* Date field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_DATE,
|
||||
/** Day of year field */
|
||||
/**
|
||||
* Day of year field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_DAY_OF_YEAR,
|
||||
/** Day of week field */
|
||||
/**
|
||||
* Day of week field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_DAY_OF_WEEK,
|
||||
/** Day of week in month field */
|
||||
/**
|
||||
* Day of week in month field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_DAY_OF_WEEK_IN_MONTH,
|
||||
/** AM/PM field */
|
||||
/**
|
||||
* AM/PM field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_AM_PM,
|
||||
/** Hour field */
|
||||
/**
|
||||
* Hour field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_HOUR,
|
||||
/** Hour of day field */
|
||||
/**
|
||||
* Hour of day field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_HOUR_OF_DAY,
|
||||
/** Minute field */
|
||||
/**
|
||||
* Minute field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_MINUTE,
|
||||
/** Second field */
|
||||
/**
|
||||
* Second field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_SECOND,
|
||||
/** Millisecond field */
|
||||
/**
|
||||
* Millisecond field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_MILLISECOND,
|
||||
/** Zone offset field */
|
||||
/**
|
||||
* Zone offset field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_ZONE_OFFSET,
|
||||
/** DST offset field */
|
||||
/**
|
||||
* DST offset field
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_DST_OFFSET,
|
||||
/** Year / week of year */
|
||||
/**
|
||||
* Year / week of year
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_YEAR_WOY,
|
||||
/** Day of week, localized (1..7) */
|
||||
/**
|
||||
* Day of week, localized (1..7)
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_DOW_LOCAL,
|
||||
/** Year of this calendar system, encompassing all supra-year fields. For example, in Gregorian/Julian calendars, positive Extended Year values indicate years AD, 1 BC = -1 extended, 2 BC = -2 extended, and so on. */
|
||||
/**
|
||||
* Year of this calendar system, encompassing all supra-year fields. For example, in Gregorian/Julian calendars, positive Extended Year values indicate years AD, 1 BC = -1 extended, 2 BC = -2 extended, and so on.
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
UCAL_EXTENDED_YEAR,
|
||||
/** Modified Julian day number, encompassing all date-related fields. Demarcates at local midnight.*/
|
||||
/**
|
||||
* Modified Julian day number, encompassing all date-related fields. Demarcates at local midnight.
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
UCAL_JULIAN_DAY,
|
||||
/** Ranges from 0 to 23:59:59.999 (regardless of DST). This field behaves <em>exactly</em> like a composite of all time-related fields, not including the zone fields. As such, it also reflects discontinuities of those fields on DST transition days. On a day of DST onset, it will jump forward. On a day of DST cessation, it will jump backward. This reflects the fact that is must be combined with the DST_OFFSET field to obtain a unique local time value. */
|
||||
/**
|
||||
* Ranges from 0 to 23:59:59.999 (regardless of DST). This field behaves <em>exactly</em> like a composite of all time-related fields, not including the zone fields. As such, it also reflects discontinuities of those fields on DST transition days. On a day of DST onset, it will jump forward. On a day of DST cessation, it will jump backward. This reflects the fact that is must be combined with the DST_OFFSET field to obtain a unique local time value.
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
UCAL_MILLISECONDS_IN_DAY,
|
||||
/** Field count */
|
||||
/**
|
||||
* Field count
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
UCAL_FIELD_COUNT,
|
||||
|
||||
/** Synonym for UCAL_DATE - @internal **/
|
||||
/**
|
||||
* Synonym for UCAL_DATE -
|
||||
* @draft ICU 2.8
|
||||
**/
|
||||
UCAL_DAY_OF_MONTH=UCAL_DATE
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue