UErrorCode err = U_ZERO_ERROR;
char locale[ULOC_FULLNAME_CAPACITY];
GetLocale(localeName, locale, ULOC_FULLNAME_CAPACITY, false, &err);
-
- if (U_FAILURE(err))
- return 0;
-
UEnumeration* pEnum = ucal_getKeywordValuesForLocale("calendar", locale, TRUE, &err);
-
- if (U_FAILURE(err))
- return 0;
-
int stringEnumeratorCount = uenum_count(pEnum, &err);
- if (U_FAILURE(err))
- {
- uenum_close(pEnum);
- return 0;
- }
-
int calendarsReturned = 0;
for (int i = 0; i < stringEnumeratorCount && calendarsReturned < calendarsCapacity; i++)
{
}
}
}
-
uenum_close(pEnum);
return calendarsReturned;
}
{
UErrorCode err = U_ZERO_ERROR;
UDateTimePatternGenerator* pGenerator = udatpg_open(locale, &err);
-
- if (U_FAILURE(err))
- return GetResultCode(err);
-
udatpg_getBestPattern(pGenerator, UDAT_MONTH_DAY_UCHAR, -1, sMonthDay, stringCapacity, &err);
-
udatpg_close(pGenerator);
return GetResultCode(err);
}
ucal_set(pCal, UCAL_DATE, 1);
int32_t currentEra;
- for (int i = 0; i <= 12; i++)
+ for (int i = 0; U_SUCCESS(err) && i <= 12; i++)
{
currentEra = ucal_get(pCal, UCAL_ERA, &err);
- if (U_FAILURE(err))
- {
- ucal_close(pCal);
- return false;
- }
-
if (currentEra == era)
{
- for (int i = 0; i < 31; i++)
+ for (int i = 0; U_SUCCESS(err) && i < 31; i++)
{
// subtract 1 day at a time until we get out of the specified Era
ucal_add(pCal, UCAL_DATE, -1, &err);
- if (U_FAILURE(err))
- {
- ucal_close(pCal);
- return false;
- }
-
currentEra = ucal_get(pCal, UCAL_ERA, &err);
- if (U_FAILURE(err))
- {
- ucal_close(pCal);
- return false;
- }
-
- if (currentEra != era)
+ if (U_SUCCESS(err) && currentEra != era)
{
// add back 1 day to get back into the specified Era
ucal_add(pCal, UCAL_DATE, 1, &err);
- if (U_FAILURE(err))
- {
- ucal_close(pCal);
- return false;
- }
-
*startMonth =
ucal_get(pCal, UCAL_MONTH, &err) + 1; // ICU Calendar months are 0-based, but .NET is 1-based
- if (U_FAILURE(err))
- {
- ucal_close(pCal);
- return false;
- }
-
*startDay = ucal_get(pCal, UCAL_DATE, &err);
ucal_close(pCal);
- if (U_FAILURE(err))
- return false;
- return true;
+ return U_SUCCESS(err);
}
}
}
// add 1 month at a time until we get into the specified Era
ucal_add(pCal, UCAL_MONTH, 1, &err);
- if (U_FAILURE(err))
- {
- ucal_close(pCal);
- return false;
- }
}
ucal_close(pCal);
{
UErrorCode status = U_ZERO_ERROR;
UNumberFormat* pFormat = unum_open(UNUM_DECIMAL, NULL, 0, locale, NULL, &status);
-
- if (U_FAILURE(status))
- return status;
-
unum_getSymbol(pFormat, symbol, value, valueLength, &status);
-
unum_close(pFormat);
return status;
}
{
UErrorCode status = U_ZERO_ERROR;
UDateFormat* pFormat = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, locale, NULL, 0, NULL, 0, &status);
-
- if (U_FAILURE(status))
- return status;
-
udat_getSymbols(pFormat, UDAT_AM_PMS, am ? 0 : 1, value, valueLength, &status);
-
udat_close(pFormat);
return status;
}
return U_MEMORY_ALLOCATION_ERROR;
}
- status = U_ZERO_ERROR;
-
uloc_getLanguage(locale, buf, length, &status);
if (U_SUCCESS(status))
UErrorCode err = U_ZERO_ERROR;
char locale[ULOC_FULLNAME_CAPACITY];
GetLocale(localeName, locale, ULOC_FULLNAME_CAPACITY, false, &err);
-
- if (U_FAILURE(err))
- {
- return UErrorCodeToBool(U_ILLEGAL_ARGUMENT_ERROR);
- }
-
UDateFormatStyle style = (shortFormat != 0) ? UDAT_SHORT : UDAT_MEDIUM;
UDateFormat* pFormat = udat_open(style, UDAT_NONE, locale, NULL, 0, NULL, 0, &err);
-
- if (U_FAILURE(err))
- return UErrorCodeToBool(err);
-
udat_toPattern(pFormat, false, value, valueLength, &err);
-
udat_close(pFormat);
return UErrorCodeToBool(err);
}