mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-22159 Merge inDaylightTime to Calendar
All the subclass implementation of inDaylightTime are the same so just move to a base class implementation.
This commit is contained in:
parent
9f3feed545
commit
294b26eb7a
16 changed files with 14 additions and 179 deletions
|
@ -2869,7 +2869,20 @@ Calendar::getActualMinimum(UCalendarDateFields field, UErrorCode& status) const
|
|||
|
||||
// -------------------------------------
|
||||
|
||||
UBool
|
||||
Calendar::inDaylightTime(UErrorCode& status) const
|
||||
{
|
||||
if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force an update of the state of the Calendar.
|
||||
((Calendar*)this)->complete(status); // cast away const
|
||||
|
||||
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : false);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
/**
|
||||
* Ensure that each field is within its valid range by calling {@link
|
||||
|
|
|
@ -86,19 +86,6 @@ CECalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType) cons
|
|||
return LIMITS[field][limitType];
|
||||
}
|
||||
|
||||
UBool
|
||||
CECalendar::inDaylightTime(UErrorCode& status) const
|
||||
{
|
||||
if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force an update of the state of the Calendar.
|
||||
((CECalendar*)this)->complete(status); // cast away const
|
||||
|
||||
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : false);
|
||||
}
|
||||
|
||||
UBool
|
||||
CECalendar::haveDefaultCentury() const
|
||||
{
|
||||
|
|
|
@ -76,17 +76,6 @@ protected:
|
|||
*/
|
||||
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override;
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) Return true if the current date for this Calendar is in
|
||||
* Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
|
||||
*
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @return True if the current date for this Calendar is in Daylight Savings Time,
|
||||
* false, otherwise.
|
||||
* @internal
|
||||
*/
|
||||
virtual UBool inDaylightTime(UErrorCode&) const override;
|
||||
|
||||
/**
|
||||
* Returns true because Coptic/Ethiopic Calendar does have a default century
|
||||
* @internal
|
||||
|
|
|
@ -826,19 +826,6 @@ void ChineseCalendar::offsetMonth(int32_t newMoon, int32_t dom, int32_t delta) {
|
|||
}
|
||||
|
||||
|
||||
UBool
|
||||
ChineseCalendar::inDaylightTime(UErrorCode& status) const
|
||||
{
|
||||
// copied from GregorianCalendar
|
||||
if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
|
||||
return false;
|
||||
|
||||
// Force an update of the state of the Calendar.
|
||||
((ChineseCalendar*)this)->complete(status); // cast away const
|
||||
|
||||
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : false);
|
||||
}
|
||||
|
||||
// default century
|
||||
|
||||
static UDate gSystemDefaultCenturyStart = DBL_MIN;
|
||||
|
|
|
@ -229,18 +229,6 @@ class U_I18N_API ChineseCalendar : public Calendar {
|
|||
|
||||
|
||||
protected:
|
||||
/**
|
||||
* (Overrides Calendar) Return true if the current date for this Calendar is in
|
||||
* Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
|
||||
*
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @return True if the current date for this Calendar is in Daylight Savings Time,
|
||||
* false, otherwise.
|
||||
* @internal
|
||||
*/
|
||||
virtual UBool inDaylightTime(UErrorCode& status) const override;
|
||||
|
||||
|
||||
/**
|
||||
* Returns true because the Islamic Calendar does have a default century
|
||||
* @internal
|
||||
|
|
|
@ -1235,20 +1235,6 @@ int32_t GregorianCalendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy,
|
|||
}
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
UBool
|
||||
GregorianCalendar::inDaylightTime(UErrorCode& status) const
|
||||
{
|
||||
if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
|
||||
return false;
|
||||
|
||||
// Force an update of the state of the Calendar.
|
||||
((GregorianCalendar*)this)->complete(status); // cast away const
|
||||
|
||||
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : false);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
/**
|
||||
|
|
|
@ -666,19 +666,6 @@ int32_t HebrewCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, UB
|
|||
return (int) (day + 347997);
|
||||
}
|
||||
|
||||
UBool
|
||||
HebrewCalendar::inDaylightTime(UErrorCode& status) const
|
||||
{
|
||||
// copied from GregorianCalendar
|
||||
if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
|
||||
return false;
|
||||
|
||||
// Force an update of the state of the Calendar.
|
||||
((HebrewCalendar*)this)->complete(status); // cast away const
|
||||
|
||||
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : false);
|
||||
}
|
||||
|
||||
/**
|
||||
* The system maintains a static default century start date and Year. They are
|
||||
* initialized the first time they are used. Once the system default century date
|
||||
|
|
|
@ -366,18 +366,6 @@ public:
|
|||
virtual void validateField(UCalendarDateFields field, UErrorCode &status) override;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) Return true if the current date for this Calendar is in
|
||||
* Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
|
||||
*
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @return True if the current date for this Calendar is in Daylight Savings Time,
|
||||
* false, otherwise.
|
||||
* @internal
|
||||
*/
|
||||
virtual UBool inDaylightTime(UErrorCode& status) const override;
|
||||
|
||||
/**
|
||||
* Returns true because the Hebrew Calendar does have a default century
|
||||
* @internal
|
||||
|
|
|
@ -297,21 +297,6 @@ void IndianCalendar::handleComputeFields(int32_t julianDay, UErrorCode& /* stat
|
|||
internalSet(UCAL_DAY_OF_YEAR, yday + 1); // yday is 0-based
|
||||
}
|
||||
|
||||
UBool
|
||||
IndianCalendar::inDaylightTime(UErrorCode& status) const
|
||||
{
|
||||
// copied from GregorianCalendar
|
||||
if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force an update of the state of the Calendar.
|
||||
((IndianCalendar*)this)->complete(status); // cast away const
|
||||
|
||||
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The system maintains a static default century start date and Year. They are
|
||||
* initialized the first time they are used. Once the system default century date
|
||||
|
|
|
@ -289,19 +289,6 @@ private:
|
|||
|
||||
// Default century.
|
||||
protected:
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) Return true if the current date for this Calendar is in
|
||||
* Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
|
||||
*
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @return True if the current date for this Calendar is in Daylight Savings Time,
|
||||
* false, otherwise.
|
||||
* @internal
|
||||
*/
|
||||
virtual UBool inDaylightTime(UErrorCode& status) const override;
|
||||
|
||||
|
||||
/**
|
||||
* Returns true because the Indian Calendar does have a default century
|
||||
* @internal
|
||||
|
|
|
@ -692,19 +692,6 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status)
|
|||
internalSet(UCAL_DAY_OF_YEAR, dayOfYear);
|
||||
}
|
||||
|
||||
UBool
|
||||
IslamicCalendar::inDaylightTime(UErrorCode& status) const
|
||||
{
|
||||
// copied from GregorianCalendar
|
||||
if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
|
||||
return false;
|
||||
|
||||
// Force an update of the state of the Calendar.
|
||||
((IslamicCalendar*)this)->complete(status); // cast away const
|
||||
|
||||
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : false);
|
||||
}
|
||||
|
||||
/**
|
||||
* The system maintains a static default century start date and Year. They are
|
||||
* initialized the first time they are used. Once the system default century date
|
||||
|
|
|
@ -381,19 +381,6 @@ class U_I18N_API IslamicCalendar : public Calendar {
|
|||
|
||||
// Default century.
|
||||
protected:
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) Return true if the current date for this Calendar is in
|
||||
* Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
|
||||
*
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @return True if the current date for this Calendar is in Daylight Savings Time,
|
||||
* false, otherwise.
|
||||
* @internal
|
||||
*/
|
||||
virtual UBool inDaylightTime(UErrorCode& status) const override;
|
||||
|
||||
|
||||
/**
|
||||
* Returns true because the Islamic Calendar does have a default century
|
||||
* @internal
|
||||
|
|
|
@ -233,19 +233,6 @@ void PersianCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*statu
|
|||
internalSet(UCAL_DAY_OF_YEAR, dayOfYear);
|
||||
}
|
||||
|
||||
UBool
|
||||
PersianCalendar::inDaylightTime(UErrorCode& status) const
|
||||
{
|
||||
// copied from GregorianCalendar
|
||||
if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
|
||||
return false;
|
||||
|
||||
// Force an update of the state of the Calendar.
|
||||
((PersianCalendar*)this)->complete(status); // cast away const
|
||||
|
||||
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : false);
|
||||
}
|
||||
|
||||
// default century
|
||||
|
||||
static UDate gSystemDefaultCenturyStart = DBL_MIN;
|
||||
|
|
|
@ -282,18 +282,6 @@ class PersianCalendar : public Calendar {
|
|||
PersianCalendar(); // default constructor not implemented
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) Return true if the current date for this Calendar is in
|
||||
* Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
|
||||
*
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @return True if the current date for this Calendar is in Daylight Savings Time,
|
||||
* false, otherwise.
|
||||
* @internal
|
||||
*/
|
||||
virtual UBool inDaylightTime(UErrorCode& status) const override;
|
||||
|
||||
/**
|
||||
* Returns true because the Persian Calendar does have a default century
|
||||
* @internal
|
||||
|
|
|
@ -870,7 +870,7 @@ public:
|
|||
* false, otherwise.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UBool inDaylightTime(UErrorCode& status) const = 0;
|
||||
virtual UBool inDaylightTime(UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Specifies whether or not date/time interpretation is to be lenient. With lenient
|
||||
|
|
|
@ -423,17 +423,6 @@ public:
|
|||
*/
|
||||
virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const override;
|
||||
|
||||
/**
|
||||
* (Overrides Calendar) Return true if the current date for this Calendar is in
|
||||
* Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
|
||||
*
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @return True if the current date for this Calendar is in Daylight Savings Time,
|
||||
* false, otherwise.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UBool inDaylightTime(UErrorCode& status) const override;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue