当前位置: 首页>>代码示例>>C++>>正文


C++ TimeZone::getDisplayName方法代码示例

本文整理汇总了C++中TimeZone::getDisplayName方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeZone::getDisplayName方法的具体用法?C++ TimeZone::getDisplayName怎么用?C++ TimeZone::getDisplayName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimeZone的用法示例。


在下文中一共展示了TimeZone::getDisplayName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getDisplayTimeZoneNative

static jstring getDisplayTimeZoneNative(JNIEnv* env, jclass clazz,
        jstring zoneID, jboolean isDST, jint style, jstring localeID) {

    // Build TimeZone object
    const jchar* idChars = env->GetStringChars(zoneID, NULL);
    jint idLength = env->GetStringLength(zoneID);
    UnicodeString idString((UChar*)idChars, idLength);
    TimeZone* zone = TimeZone::createTimeZone(idString);
    env->ReleaseStringChars(zoneID, idChars);

    // Build Locale object (can we rely on zero termination of JNI result?)
    const char* localeChars = env->GetStringUTFChars(localeID, NULL);
    jint localeLength = env->GetStringLength(localeID);
    Locale locale = Locale::createFromName(localeChars);

    // Try to get the display name of the TimeZone according to the Locale
    UnicodeString buffer;
    zone->getDisplayName((UBool)isDST, (style == 0 ? TimeZone::SHORT : TimeZone::LONG), locale, buffer);
    const UChar* tempChars = buffer.getBuffer();
    int tempLength = buffer.length();
    jstring result = env->NewString((jchar*)tempChars, tempLength);
    env->ReleaseStringUTFChars(localeID, localeChars);

    // Clean up everything
    delete(zone);
    
    return result;
}
开发者ID:llnull,项目名称:platform_dalvik,代码行数:28,代码来源:ResourceInterface.cpp

示例2: TIMEZONE_Get_display_name

void TIMEZONE_Get_display_name(sLONG_PTR *pResult, PackagePtr pParams)
{
	C_TEXT Param1;
	C_TEXT Param2;
	C_LONGINT returnValue;
	
	Param1.fromParamAtIndex(pParams, 1);
	
	UErrorCode status = U_ZERO_ERROR;
	
	Param1.fromParamAtIndex(pParams, 1);
	UnicodeString zoneId = UnicodeString((const UChar *)Param1.getUTF16StringPtr());
	TimeZone *zone = TimeZone::createTimeZone(zoneId);
	
	if(zone){
		
		UnicodeString displayName;
		zone->getDisplayName (displayName);
		
		DT::setUnicodeString(Param2, displayName);
		
		delete zone;
		
	}else{
		status = U_ILLEGAL_ARGUMENT_ERROR;
	}
	
	returnValue.setIntValue(status);
	
	Param2.toParamAtIndex(pParams, 2);
	returnValue.setReturn(pResult);
}
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:4d-plugin-time-and-number,代码行数:32,代码来源:4DPlugin.cpp

示例3: offsetFromUtcToTz

int TimezoneUtils::offsetFromUtcToTz(QDateTime date, QString timezoneId, bool ignoreDstOffset, bool* error)
{
    int offset = 0;
    UErrorCode errorCode = U_ZERO_ERROR;

    // get timezone object
    TimeZone* tz = TimeZone::createTimeZone(reinterpret_cast<UChar*>(timezoneId.data()));
    if (!tz) {
        *error = true;
        return 0;
    }

    UnicodeString name;
    tz->getDisplayName(name);

    // get offset
    // cal takes ownership of tz - tried to delete it and got an error
    Calendar* cal = Calendar::createInstance(tz, errorCode);
    if (!cal || errorCode > 0) {
        *error = true;
        return 0;
    }
    cal->set(date.date().year(), date.date().month(), date.date().day(), date.time().hour(), date.time().minute());
    UDate udate = cal->getTime(errorCode);
    if (errorCode > 0) {
        *error = true;
        delete cal;
        return 0;
    }

    UBool isGmt = false;
    int32_t rawOffset = 0;
    int32_t dstOffset = 0;
    tz->getOffset(udate, isGmt, rawOffset, dstOffset, errorCode);
    if (errorCode > 0) {
        *error = true;
        delete cal;
        return 0;
    }

    if (!ignoreDstOffset) {
        offset = rawOffset + dstOffset;
    } else {
        offset = rawOffset;
    }
    delete cal;

    offset /= 1000;
    *error = false;

    return offset;
}
开发者ID:RonMen,项目名称:BB10-WebWorks-Framework,代码行数:52,代码来源:timezone_utils.cpp

示例4: getDisplayTimeZoneNative

static jstring getDisplayTimeZoneNative(JNIEnv* env, jclass clazz,
        jstring zoneId, jboolean isDST, jint style, jstring localeId) {

    TimeZone* zone = timeZoneFromId(env, zoneId);
    Locale locale = getLocale(env, localeId);

    // Try to get the display name of the TimeZone according to the Locale
    UnicodeString displayName;
    zone->getDisplayName((UBool)isDST, (style == 0 ? TimeZone::SHORT : TimeZone::LONG), locale, displayName);
    jstring result = env->NewString(displayName.getBuffer(), displayName.length());
    delete zone;
    return result;
}
开发者ID:Ar3kkusu,项目名称:android_libcore,代码行数:13,代码来源:Resources.cpp

示例5: stri_timezone_info

/** Get localized time zone info
 *
 * @param tz single string or NULL
 * @param locale single string or NULL
 * @param display_type single string
 * @return list
 *
 * @version 0.5-1 (Marek Gagolewski, 2014-12-24)
 *
 * @version 0.5-1 (Marek Gagolewski, 2015-03-01)
 *    new out: WindowsID, NameDaylight, new in: display_type
 */
SEXP stri_timezone_info(SEXP tz, SEXP locale, SEXP display_type) {
   TimeZone* curtz = stri__prepare_arg_timezone(tz, "tz", R_NilValue);
   const char* qloc = stri__prepare_arg_locale(locale, "locale", true); /* this is R_alloc'ed */
   const char* dtype_str = stri__prepare_arg_string_1_notNA(display_type, "display_type"); /* this is R_alloc'ed */
   const char* dtype_opts[] = {
      "short", "long", "generic_short", "generic_long", "gmt_short", "gmt_long",
      "common", "generic_location",
      NULL};
   int dtype_cur = stri__match_arg(dtype_str, dtype_opts);

   TimeZone::EDisplayType dtype;
   switch (dtype_cur) {
      case 0:  dtype = TimeZone::SHORT; break;
      case 1:  dtype = TimeZone::LONG; break;
      case 2:  dtype = TimeZone::SHORT_GENERIC; break;
      case 3:  dtype = TimeZone::LONG_GENERIC; break;
      case 4:  dtype = TimeZone::SHORT_GMT; break;
      case 5:  dtype = TimeZone::LONG_GMT; break;
      case 6:  dtype = TimeZone::SHORT_COMMONLY_USED; break;
      case 7:  dtype = TimeZone::GENERIC_LOCATION; break;
      default: Rf_error(MSG__INCORRECT_MATCH_OPTION, "display_type"); break;
   }

   const R_len_t infosize = 6;
   SEXP vals;

   PROTECT(vals = Rf_allocVector(VECSXP, infosize));
   for (int i=0; i<infosize; ++i)
      SET_VECTOR_ELT(vals, i, R_NilValue);

   R_len_t curidx = -1;

   ++curidx;
   UnicodeString val_ID;
   curtz->getID(val_ID);
   SET_VECTOR_ELT(vals, curidx, stri__make_character_vector_UnicodeString_ptr(1, &val_ID));

   ++curidx;
   UnicodeString val_name;
   curtz->getDisplayName(false, dtype, Locale::createFromName(qloc), val_name);
   SET_VECTOR_ELT(vals, curidx, stri__make_character_vector_UnicodeString_ptr(1, &val_name));

   ++curidx;
   if ((bool)curtz->useDaylightTime()) {
      UnicodeString val_name2;
      curtz->getDisplayName(true, dtype, Locale::createFromName(qloc), val_name2);
      SET_VECTOR_ELT(vals, curidx, stri__make_character_vector_UnicodeString_ptr(1, &val_name2));
   }
   else
      SET_VECTOR_ELT(vals, curidx, Rf_ScalarString(NA_STRING));

   ++curidx;
   UnicodeString val_windows;
   UErrorCode status = U_ZERO_ERROR;
#if U_ICU_VERSION_MAJOR_NUM>=52
   TimeZone::getWindowsID(val_ID, val_windows, status); // Stable since ICU 52
#endif
   if (U_SUCCESS(status) && val_windows.length() > 0)
      SET_VECTOR_ELT(vals, curidx, stri__make_character_vector_UnicodeString_ptr(1, &val_windows));
   else
      SET_VECTOR_ELT(vals, curidx, Rf_ScalarString(NA_STRING));

   ++curidx;
   SET_VECTOR_ELT(vals, curidx, Rf_ScalarReal(curtz->getRawOffset()/1000.0/3600.0));

   ++curidx;
   SET_VECTOR_ELT(vals, curidx, Rf_ScalarLogical((bool)curtz->useDaylightTime()));

   delete curtz;
   stri__set_names(vals, infosize, "ID", "Name", "Name.Daylight", "Name.Windows", "RawOffset", "UsesDaylightTime");
   UNPROTECT(1);
   return vals;
}
开发者ID:GuillaumeSmaha,项目名称:stringi,代码行数:85,代码来源:stri_time_zone.cpp


注:本文中的TimeZone::getDisplayName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。