Add BLocaleRoster::GetAvailableTimeZonesWithRegionInfo()
* allow locale kit clients to get all timezones with their corresponding country/region ID piecemeal
This commit is contained in:
parent
3c1afd351d
commit
635df64352
@ -45,6 +45,8 @@ public:
|
|||||||
BMessage* timeZones) const;
|
BMessage* timeZones) const;
|
||||||
status_t GetAvailableTimeZones(
|
status_t GetAvailableTimeZones(
|
||||||
BMessage* timeZones) const;
|
BMessage* timeZones) const;
|
||||||
|
status_t GetAvailableTimeZonesWithRegionInfo(
|
||||||
|
BMessage* timeZonesWithRegonInfo) const;
|
||||||
status_t GetAvailableTimeZonesForCountry(
|
status_t GetAvailableTimeZonesForCountry(
|
||||||
BMessage* message,
|
BMessage* message,
|
||||||
const char* countryCode) const;
|
const char* countryCode) const;
|
||||||
|
@ -279,6 +279,47 @@ BLocaleRoster::GetAvailableTimeZones(BMessage* timeZones) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BLocaleRoster::GetAvailableTimeZonesWithRegionInfo(BMessage* timeZones) const
|
||||||
|
{
|
||||||
|
if (!timeZones)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
status_t status = B_OK;
|
||||||
|
|
||||||
|
UErrorCode icuStatus = U_ZERO_ERROR;
|
||||||
|
|
||||||
|
StringEnumeration* zoneList = TimeZone::createTimeZoneIDEnumeration(
|
||||||
|
UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, icuStatus);
|
||||||
|
|
||||||
|
int32 count = zoneList->count(icuStatus);
|
||||||
|
if (U_SUCCESS(icuStatus)) {
|
||||||
|
for (int i = 0; i < count; ++i) {
|
||||||
|
const char* zoneID = zoneList->next(NULL, icuStatus);
|
||||||
|
if (zoneID == NULL || !U_SUCCESS(icuStatus)) {
|
||||||
|
status = B_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
timeZones->AddString("timeZone", zoneID);
|
||||||
|
|
||||||
|
char region[5];
|
||||||
|
icuStatus = U_ZERO_ERROR;
|
||||||
|
TimeZone::getRegion(zoneID, region, 5, icuStatus);
|
||||||
|
if (!U_SUCCESS(icuStatus)) {
|
||||||
|
status = B_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
timeZones->AddString("region", region);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
status = B_ERROR;
|
||||||
|
|
||||||
|
delete zoneList;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BLocaleRoster::GetAvailableTimeZonesForCountry(BMessage* timeZones,
|
BLocaleRoster::GetAvailableTimeZonesForCountry(BMessage* timeZones,
|
||||||
const char* countryCode) const
|
const char* countryCode) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user