Skip to content

Commit

Permalink
ICU-22991 clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang committed Jan 8, 2025
1 parent e700e4a commit 82da5a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions icu4c/source/i18n/gregoimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ int64_t Grego::fieldsToDay(int32_t year, int32_t month, int32_t dom) {

void Grego::dayToFields(int32_t day, int32_t& year, int8_t& month,
int8_t& dom, int8_t& dow, int16_t& doy, UErrorCode& status) {
year = dayToYear(day, doy, status);
UBool isLeap = isLeapYear(year);
year = dayToYear(day, doy, status); // one-based doy
if (U_FAILURE(status)) return;

// Convert from 1970 CE epoch to 1 CE epoch (Gregorian calendar)
if (uprv_add32_overflow(day, JULIAN_1970_CE - JULIAN_1_CE, &day)) {
Expand All @@ -134,6 +134,7 @@ void Grego::dayToFields(int32_t day, int32_t& year, int8_t& month,

// Common Julian/Gregorian calculation
int32_t correction = 0;
bool isLeap = isLeapYear(year);
int32_t march1 = isLeap ? 60 : 59; // zero-based DOY for March 1
if (doy > march1) {
correction = isLeap ? 1 : 2;
Expand Down Expand Up @@ -180,6 +181,7 @@ void Grego::dayToFields(int32_t day, int32_t& year, int8_t& month,
int16_t unusedDOY;
dayToFields(day, year, month, dom, dow, unusedDOY, status);
}

void Grego::dayToFields(int32_t day, int32_t& year, int8_t& month,
int8_t& dom, int16_t& doy, UErrorCode& status) {
int8_t unusedDOW;
Expand All @@ -191,11 +193,13 @@ void Grego::timeToFields(UDate time, int32_t& year, int8_t& month,
int8_t unusedDOW;
timeToFields(time, year, month, dom, unusedDOW, mid, status);
}

void Grego::timeToFields(UDate time, int32_t& year, int8_t& month,
int8_t& dom, int8_t& dow, int32_t& mid, UErrorCode& status) {
int16_t unusedDOY;
timeToFields(time, year, month, dom, dow, unusedDOY, mid, status);
}

void Grego::timeToFields(UDate time, int32_t& year, int8_t& month,
int8_t& dom, int8_t& dow, int16_t& doy, int32_t& mid, UErrorCode& status) {
if (U_FAILURE(status)) return;
Expand Down

0 comments on commit 82da5a2

Please sign in to comment.