Skip to content

Commit

Permalink
ICU-22421 Remove two unused internal methods in gregorian cal
Browse files Browse the repository at this point in the history
Remove pinDayOfMonth() and yearLength(int32_t year)
from GregorianCalendar.

These two methods are
1. Unused by any code inside ICU, not in source/{common,i18n,test}.
2. Marked as @internal in the header.
3. Wrap inside #ifndef U_HIDE_INTERNAL_API block in the header
4. In "protected:" section.
5. No ICU4J counterpart.

The yearLength(int32_t year) dup the functionality as
handleGetYearLength of the same class and that one is the correct one to
be keep and used..
There is another yearLength() w/o the year as parameter should NOT be
removed and still needed internally.
  • Loading branch information
FrankYFTang committed Jun 22, 2023
1 parent e83b071 commit 26bd70e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
26 changes: 0 additions & 26 deletions icu4c/source/i18n/gregocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,6 @@ GregorianCalendar::monthLength(int32_t month, int32_t year) const

// -------------------------------------

int32_t
GregorianCalendar::yearLength(int32_t year) const
{
return isLeapYear(year) ? 366 : 365;
}

// -------------------------------------

int32_t
GregorianCalendar::yearLength() const
{
Expand All @@ -626,24 +618,6 @@ GregorianCalendar::yearLength() const

// -------------------------------------

/**
* 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
* 3, we want it to go to Feb 28. Adjustments which might run into this
* problem call this method to retain the proper month.
*/
void
GregorianCalendar::pinDayOfMonth()
{
int32_t monthLen = monthLength(internalGetMonth());
int32_t dom = internalGet(UCAL_DATE);
if(dom > monthLen)
set(UCAL_DATE, monthLen);
}

// -------------------------------------


UBool
GregorianCalendar::validateFields() const
{
Expand Down
16 changes: 0 additions & 16 deletions icu4c/source/i18n/unicode/gregocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,29 +536,13 @@ class U_I18N_API GregorianCalendar: public Calendar {
virtual int32_t monthLength(int32_t month, int32_t year) const;

#ifndef U_HIDE_INTERNAL_API
/**
* return the length of the given year.
* @param year the given year.
* @return the length of the given year.
* @internal
*/
int32_t yearLength(int32_t year) const;

/**
* return the length of the year field.
* @return the length of the year field
* @internal
*/
int32_t yearLength(void) const;

/**
* 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
* 3, we want it to go to Feb 28. Adjustments which might run into this
* problem call this method to retain the proper month.
* @internal
*/
void pinDayOfMonth(void);
#endif /* U_HIDE_INTERNAL_API */

/**
Expand Down

0 comments on commit 26bd70e

Please sign in to comment.