本文整理汇总了C++中GregorianCalendar::adoptTimeZone方法的典型用法代码示例。如果您正苦于以下问题:C++ GregorianCalendar::adoptTimeZone方法的具体用法?C++ GregorianCalendar::adoptTimeZone怎么用?C++ GregorianCalendar::adoptTimeZone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GregorianCalendar
的用法示例。
在下文中一共展示了GregorianCalendar::adoptTimeZone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _php_intlgregcal_constructor_body
//.........这里部分代码省略.........
"|z!s!", &tz_object, &locale, &locale_len) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: bad arguments", 0 TSRMLS_CC);
Z_OBJ_P(return_value) = NULL;
return;
}
}
if (variant > 2 && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"lll|lll", &largs[0], &largs[1], &largs[2], &largs[3], &largs[4],
&largs[5]) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: bad arguments", 0 TSRMLS_CC);
Z_OBJ_P(return_value) = NULL;
return;
}
// instantion of ICU object
GregorianCalendar *gcal = NULL;
if (variant <= 2) {
// From timezone and locale (0 to 2 arguments)
TimeZone *tz = timezone_process_timezone_argument(tz_object, NULL,
"intlgregcal_create_instance" TSRMLS_CC);
if (tz == NULL) {
Z_OBJ_P(return_value) = NULL;
return;
}
if (!locale) {
locale = const_cast<char*>(intl_locale_get_default(TSRMLS_C));
}
gcal = new GregorianCalendar(tz, Locale::createFromName(locale),
status);
if (U_FAILURE(status)) {
intl_error_set(NULL, status, "intlgregcal_create_instance: error "
"creating ICU GregorianCalendar from time zone and locale", 0 TSRMLS_CC);
if (gcal) {
delete gcal;
}
delete tz;
Z_OBJ_P(return_value) = NULL;
return;
}
} else {
// From date/time (3, 5 or 6 arguments)
for (int i = 0; i < variant; i++) {
if (largs[i] < INT32_MIN || largs[i] > INT32_MAX) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: at least one of the arguments"
" has an absolute value that is too large", 0 TSRMLS_CC);
Z_OBJ_P(return_value) = NULL;
return;
}
}
if (variant == 3) {
gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1],
(int32_t)largs[2], status);
} else if (variant == 5) {
gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1],
(int32_t)largs[2], (int32_t)largs[3], (int32_t)largs[4], status);
} else if (variant == 6) {
gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1],
(int32_t)largs[2], (int32_t)largs[3], (int32_t)largs[4], (int32_t)largs[5],
status);
}
if (U_FAILURE(status)) {
intl_error_set(NULL, status, "intlgregcal_create_instance: error "
"creating ICU GregorianCalendar from date", 0 TSRMLS_CC);
if (gcal) {
delete gcal;
}
Z_OBJ_P(return_value) = NULL;
return;
}
timelib_tzinfo *tzinfo = get_timezone_info(TSRMLS_C);
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42
UnicodeString tzstr = UnicodeString::fromUTF8(StringPiece(tzinfo->name));
#else
UnicodeString tzstr = UnicodeString(tzinfo->name,
strlen(tzinfo->name), US_INV);
#endif
if (tzstr.isBogus()) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: could not create UTF-8 string "
"from PHP's default timezone name (see date_default_timezone_get())",
0 TSRMLS_CC);
delete gcal;
Z_OBJ_P(return_value) = NULL;
return;
}
TimeZone *tz = TimeZone::createTimeZone(tzstr);
gcal->adoptTimeZone(tz);
}
Calendar_object *co = Z_INTL_CALENDAR_P(return_value);
co->ucal = gcal;
}