aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/i18n/simpletz.cpp
diff options
context:
space:
mode:
authorromankoshelev <romankoshelev@yandex-team.com>2023-08-14 19:51:50 +0300
committerromankoshelev <romankoshelev@yandex-team.com>2023-08-15 01:24:11 +0300
commitcfcd865e05c0d0525ea27d1e153a043b32a85138 (patch)
tree68d3b3b25271e8a4998505897a269ff7ce119b76 /contrib/libs/icu/i18n/simpletz.cpp
parentccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff)
downloadydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/i18n/simpletz.cpp')
-rw-r--r--contrib/libs/icu/i18n/simpletz.cpp124
1 files changed, 61 insertions, 63 deletions
diff --git a/contrib/libs/icu/i18n/simpletz.cpp b/contrib/libs/icu/i18n/simpletz.cpp
index d9b0cd8e1e..8b21152f52 100644
--- a/contrib/libs/icu/i18n/simpletz.cpp
+++ b/contrib/libs/icu/i18n/simpletz.cpp
@@ -53,8 +53,8 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SimpleTimeZone)
// Gregorian calendar started.
const int8_t SimpleTimeZone::STATICMONTHLENGTH[] = {31,29,31,30,31,30,31,31,30,31,30,31};
-static const UChar DST_STR[] = {0x0028,0x0044,0x0053,0x0054,0x0029,0}; // "(DST)"
-static const UChar STD_STR[] = {0x0028,0x0053,0x0054,0x0044,0x0029,0}; // "(STD)"
+static const char16_t DST_STR[] = {0x0028,0x0044,0x0053,0x0054,0x0029,0}; // "(DST)"
+static const char16_t STD_STR[] = {0x0028,0x0053,0x0054,0x0044,0x0029,0}; // "(STD)"
// *****************************************************************************
@@ -76,7 +76,7 @@ SimpleTimeZone::SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID)
endTime(0),
startYear(0),
rawOffset(rawOffsetGMT),
- useDaylight(FALSE),
+ useDaylight(false),
startMode(DOM_MODE),
endMode(DOM_MODE),
dstSavings(U_MILLIS_PER_HOUR)
@@ -262,7 +262,7 @@ void
SimpleTimeZone::setStartYear(int32_t year)
{
startYear = year;
- transitionRulesInitialized = FALSE;
+ transitionRulesInitialized = false;
}
// -------------------------------------
@@ -316,7 +316,7 @@ SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t da
startTime = time;
startTimeMode = mode;
decodeStartRule(status);
- transitionRulesInitialized = FALSE;
+ transitionRulesInitialized = false;
}
// -------------------------------------
@@ -368,7 +368,7 @@ SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayO
endTime = time;
endTimeMode = mode;
decodeEndRule(status);
- transitionRulesInitialized = FALSE;
+ transitionRulesInitialized = false;
}
// -------------------------------------
@@ -518,9 +518,8 @@ SimpleTimeZone::getOffsetFromLocal(UDate date, UTimeZoneLocalOption nonExistingT
}
rawOffsetGMT = getRawOffset();
- int32_t year, month, dom, dow;
- double day = uprv_floor(date / U_MILLIS_PER_DAY);
- int32_t millis = (int32_t) (date - day * U_MILLIS_PER_DAY);
+ int32_t year, month, dom, dow, millis;
+ int32_t day = ClockMath::floorDivide(date, U_MILLIS_PER_DAY, &millis);
Grego::dayToFields(day, year, month, dom, dow);
@@ -532,25 +531,24 @@ SimpleTimeZone::getOffsetFromLocal(UDate date, UTimeZoneLocalOption nonExistingT
return;
}
- UBool recalc = FALSE;
+ UBool recalc = false;
// Now we need some adjustment
if (savingsDST > 0) {
if ((nonExistingTimeOpt & kStdDstMask) == kStandard
|| ((nonExistingTimeOpt & kStdDstMask) != kDaylight && (nonExistingTimeOpt & kFormerLatterMask) != kLatter)) {
date -= getDSTSavings();
- recalc = TRUE;
+ recalc = true;
}
} else {
if ((duplicatedTimeOpt & kStdDstMask) == kDaylight
|| ((duplicatedTimeOpt & kStdDstMask) != kStandard && (duplicatedTimeOpt & kFormerLatterMask) == kFormer)) {
date -= getDSTSavings();
- recalc = TRUE;
+ recalc = true;
}
}
if (recalc) {
- day = uprv_floor(date / U_MILLIS_PER_DAY);
- millis = (int32_t) (date - day * U_MILLIS_PER_DAY);
+ day = ClockMath::floorDivide(date, U_MILLIS_PER_DAY, &millis);
Grego::dayToFields(day, year, month, dom, dow);
savingsDST = getOffset(GregorianCalendar::AD, year, month, dom,
(uint8_t) dow, millis,
@@ -681,7 +679,7 @@ void
SimpleTimeZone::setRawOffset(int32_t offsetMillis)
{
rawOffset = offsetMillis;
- transitionRulesInitialized = FALSE;
+ transitionRulesInitialized = false;
}
// -------------------------------------
@@ -695,7 +693,7 @@ SimpleTimeZone::setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status)
else {
dstSavings = millisSavedDuringDST;
}
- transitionRulesInitialized = FALSE;
+ transitionRulesInitialized = false;
}
// -------------------------------------
@@ -725,12 +723,12 @@ UBool SimpleTimeZone::inDaylightTime(UDate date, UErrorCode& status) const
// This method is wasteful since it creates a new GregorianCalendar and
// deletes it each time it is called. However, this is a deprecated method
// and provided only for Java compatibility as of 8/6/97 [LIU].
- if (U_FAILURE(status)) return FALSE;
+ if (U_FAILURE(status)) return false;
GregorianCalendar *gc = new GregorianCalendar(*this, status);
- /* test for NULL */
+ /* test for nullptr */
if (gc == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
- return FALSE;
+ return false;
}
gc->setTime(date, status);
UBool result = gc->inDaylightTime(status);
@@ -748,8 +746,8 @@ UBool SimpleTimeZone::inDaylightTime(UDate date, UErrorCode& status) const
UBool
SimpleTimeZone::hasSameRules(const TimeZone& other) const
{
- if (this == &other) return TRUE;
- if (typeid(*this) != typeid(other)) return FALSE;
+ if (this == &other) return true;
+ if (typeid(*this) != typeid(other)) return false;
SimpleTimeZone *that = (SimpleTimeZone*)&other;
return rawOffset == that->rawOffset &&
useDaylight == that->useDaylight &&
@@ -872,7 +870,7 @@ SimpleTimeZone::decodeStartRule(UErrorCode& status)
{
if(U_FAILURE(status)) return;
- useDaylight = (UBool)((startDay != 0) && (endDay != 0) ? TRUE : FALSE);
+ useDaylight = (UBool)((startDay != 0) && (endDay != 0) ? true : false);
if (useDaylight && dstSavings == 0) {
dstSavings = U_MILLIS_PER_HOUR;
}
@@ -927,7 +925,7 @@ SimpleTimeZone::decodeEndRule(UErrorCode& status)
{
if(U_FAILURE(status)) return;
- useDaylight = (UBool)((startDay != 0) && (endDay != 0) ? TRUE : FALSE);
+ useDaylight = (UBool)((startDay != 0) && (endDay != 0) ? true : false);
if (useDaylight && dstSavings == 0) {
dstSavings = U_MILLIS_PER_HOUR;
}
@@ -975,13 +973,13 @@ SimpleTimeZone::decodeEndRule(UErrorCode& status)
UBool
SimpleTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const {
if (!useDaylight) {
- return FALSE;
+ return false;
}
UErrorCode status = U_ZERO_ERROR;
checkTransitionRules(status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
UDate firstTransitionTime = firstTransition->getTime();
@@ -993,74 +991,74 @@ SimpleTimeZone::getNextTransition(UDate base, UBool inclusive, TimeZoneTransitio
UBool dstAvail = dstRule->getNextStart(base, stdRule->getRawOffset(), stdRule->getDSTSavings(), inclusive, dstDate);
if (stdAvail && (!dstAvail || stdDate < dstDate)) {
result.setTime(stdDate);
- result.setFrom((const TimeZoneRule&)*dstRule);
- result.setTo((const TimeZoneRule&)*stdRule);
- return TRUE;
+ result.setFrom(*dstRule);
+ result.setTo(*stdRule);
+ return true;
}
if (dstAvail && (!stdAvail || dstDate < stdDate)) {
result.setTime(dstDate);
- result.setFrom((const TimeZoneRule&)*stdRule);
- result.setTo((const TimeZoneRule&)*dstRule);
- return TRUE;
+ result.setFrom(*stdRule);
+ result.setTo(*dstRule);
+ return true;
}
- return FALSE;
+ return false;
}
UBool
SimpleTimeZone::getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const {
if (!useDaylight) {
- return FALSE;
+ return false;
}
UErrorCode status = U_ZERO_ERROR;
checkTransitionRules(status);
if (U_FAILURE(status)) {
- return FALSE;
+ return false;
}
UDate firstTransitionTime = firstTransition->getTime();
if (base < firstTransitionTime || (!inclusive && base == firstTransitionTime)) {
- return FALSE;
+ return false;
}
UDate stdDate, dstDate;
UBool stdAvail = stdRule->getPreviousStart(base, dstRule->getRawOffset(), dstRule->getDSTSavings(), inclusive, stdDate);
UBool dstAvail = dstRule->getPreviousStart(base, stdRule->getRawOffset(), stdRule->getDSTSavings(), inclusive, dstDate);
if (stdAvail && (!dstAvail || stdDate > dstDate)) {
result.setTime(stdDate);
- result.setFrom((const TimeZoneRule&)*dstRule);
- result.setTo((const TimeZoneRule&)*stdRule);
- return TRUE;
+ result.setFrom(*dstRule);
+ result.setTo(*stdRule);
+ return true;
}
if (dstAvail && (!stdAvail || dstDate > stdDate)) {
result.setTime(dstDate);
- result.setFrom((const TimeZoneRule&)*stdRule);
- result.setTo((const TimeZoneRule&)*dstRule);
- return TRUE;
+ result.setFrom(*stdRule);
+ result.setTo(*dstRule);
+ return true;
}
- return FALSE;
+ return false;
}
void
-SimpleTimeZone::clearTransitionRules(void) {
- initialRule = NULL;
- firstTransition = NULL;
- stdRule = NULL;
- dstRule = NULL;
- transitionRulesInitialized = FALSE;
+SimpleTimeZone::clearTransitionRules() {
+ initialRule = nullptr;
+ firstTransition = nullptr;
+ stdRule = nullptr;
+ dstRule = nullptr;
+ transitionRulesInitialized = false;
}
void
-SimpleTimeZone::deleteTransitionRules(void) {
- if (initialRule != NULL) {
+SimpleTimeZone::deleteTransitionRules() {
+ if (initialRule != nullptr) {
delete initialRule;
}
- if (firstTransition != NULL) {
+ if (firstTransition != nullptr) {
delete firstTransition;
}
- if (stdRule != NULL) {
+ if (stdRule != nullptr) {
delete stdRule;
}
- if (dstRule != NULL) {
+ if (dstRule != nullptr) {
delete dstRule;
}
clearTransitionRules();
@@ -1133,7 +1131,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
return;
}
// Check for Null pointer
- if (dtRule == NULL) {
+ if (dtRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
@@ -1142,7 +1140,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
dtRule, startYear, AnnualTimeZoneRule::MAX_YEAR);
// Check for Null pointer
- if (dstRule == NULL) {
+ if (dstRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -1170,7 +1168,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
}
// Check for Null pointer
- if (dtRule == NULL) {
+ if (dtRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -1180,7 +1178,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
dtRule, startYear, AnnualTimeZoneRule::MAX_YEAR);
//Check for Null pointer
- if (stdRule == NULL) {
+ if (stdRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -1192,7 +1190,7 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
// Create a TimeZoneRule for initial time
if (firstStdStart < firstDstStart) {
initialRule = new InitialTimeZoneRule(tzid+UnicodeString(DST_STR), getRawOffset(), dstRule->getDSTSavings());
- if (initialRule == NULL) {
+ if (initialRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -1200,14 +1198,14 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
firstTransition = new TimeZoneTransition(firstStdStart, *initialRule, *stdRule);
} else {
initialRule = new InitialTimeZoneRule(tzid+UnicodeString(STD_STR), getRawOffset(), 0);
- if (initialRule == NULL) {
+ if (initialRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
}
firstTransition = new TimeZoneTransition(firstDstStart, *initialRule, *dstRule);
}
- if (firstTransition == NULL) {
+ if (firstTransition == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
@@ -1217,14 +1215,14 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
// Create a TimeZoneRule for initial time
initialRule = new InitialTimeZoneRule(tzid, getRawOffset(), 0);
// Check for null pointer.
- if (initialRule == NULL) {
+ if (initialRule == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
deleteTransitionRules();
return;
}
}
- transitionRulesInitialized = TRUE;
+ transitionRulesInitialized = true;
}
int32_t
@@ -1246,7 +1244,7 @@ SimpleTimeZone::getTimeZoneRules(const InitialTimeZoneRule*& initial,
}
initial = initialRule;
int32_t cnt = 0;
- if (stdRule != NULL) {
+ if (stdRule != nullptr) {
if (cnt < trscount) {
trsrules[cnt++] = stdRule;
}