+ UnicodeString timePattern;
+ if (timeStyle >= kFull && timeStyle <= kShort) {
+ const char* baseLoc = locale.getBaseName();
+ if (baseLoc!=NULL && baseLoc[0]!=0 && uprv_strcmp(baseLoc,"und")!=0) {
+ UErrorCode useStatus = U_ZERO_ERROR;
+ const char* validLoc = getLocaleID(ULOC_VALID_LOCALE, useStatus);
+ if (U_SUCCESS(useStatus) && uprv_strcmp(validLoc,baseLoc)!=0) {
+ char minLoc[kBaseNameMax];
+ uloc_minimizeSubtags(baseLoc, minLoc, kBaseNameMax, &useStatus);
+ minLoc[kBaseNameMax-1] = 0; // ensure zero term
+ const char* actualLoc = getLocaleID(ULOC_ACTUAL_LOCALE, useStatus);
+ if (U_SUCCESS(useStatus) && uprv_strcmp(actualLoc,minLoc)!=0) {
+ // The standard time formats may have the wrong time cycle, because:
+ // * the valid locale is not the same as the base locale, or
+ // * the actual locale the patterns are coming from is not the same
+ // as the minimized locale.
+ // We could *also* check whether they do actually have a mismatch with
+ // the time cycle preferences for the region, but that is a lot more
+ // work for little or no additional benefit, since just going ahead
+ // and always synthesizing the time format as per the following should
+ // create a locale-appropriate pattern with cycle that matches the
+ // region preferences anyway (for completely unsupported languages,
+ // this will use root patterns for the appropriate cycle for the
+ // likely subtags resion).
+ LocalPointer<DateTimePatternGenerator> dtpg(DateTimePatternGenerator::createInstance(locale, useStatus, TRUE));
+ if (U_SUCCESS(useStatus)) {
+ UnicodeString timeSkeleton(TRUE, timeSkeletons[timeStyle], -1);
+ timePattern = dtpg->getBestPattern(timeSkeleton, useStatus);
+#if DEBUG_SYNTHETIC_TIMEFMTS
+ if (timePattern.length() != 0) {
+ char bbuf[32];
+ timePattern.extract(0,timePattern.length(),bbuf,32);
+ printf("\n## for locale %s, validLoc %s, minLoc %s, actualLoc %s, synth timePat %s\n", locale.getName(), validLoc, minLoc, actualLoc, bbuf);
+ }
+#endif
+ }
+ }
+ }
+ }
+ }
+