本文整理汇总了C++中TimeZone::useDaylightTime方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeZone::useDaylightTime方法的具体用法?C++ TimeZone::useDaylightTime怎么用?C++ TimeZone::useDaylightTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeZone
的用法示例。
在下文中一共展示了TimeZone::useDaylightTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dataerrln
/**
* @bug 4126678
* CANNOT REPRODUDE
*
* Yet another _alleged_ bug in TimeZone::getOffset(), a method that never
* should have been made public. It's simply too hard to use correctly.
*
* The original test code failed to do the following:
* (1) Call Calendar::setTime() before getting the fields!
* (2) Use the right millis (as usual) for getOffset(); they were passing
* in the MILLIS field, instead of the STANDARD MILLIS IN DAY.
* When you fix these two problems, the test passes, as expected.
*/
void TimeZoneRegressionTest:: Test4126678()
{
UErrorCode status = U_ZERO_ERROR;
Calendar *cal = Calendar::createInstance(status);
if(U_FAILURE(status)) {
dataerrln("Error creating calendar %s", u_errorName(status));
delete cal;
return;
}
failure(status, "Calendar::createInstance");
TimeZone *tz = TimeZone::createTimeZone("PST");
cal->adoptTimeZone(tz);
cal->set(1998, UCAL_APRIL, 5, 10, 0);
if (! tz->useDaylightTime() || U_FAILURE(status))
dataerrln("We're not in Daylight Savings Time and we should be. - %s", u_errorName(status));
//cal.setTime(dt);
int32_t era = cal->get(UCAL_ERA, status);
int32_t year = cal->get(UCAL_YEAR, status);
int32_t month = cal->get(UCAL_MONTH, status);
int32_t day = cal->get(UCAL_DATE, status);
int32_t dayOfWeek = cal->get(UCAL_DAY_OF_WEEK, status);
int32_t millis = cal->get(UCAL_MILLISECOND, status) +
(cal->get(UCAL_SECOND, status) +
(cal->get(UCAL_MINUTE, status) +
(cal->get(UCAL_HOUR, status) * 60) * 60) * 1000) -
cal->get(UCAL_DST_OFFSET, status);
failure(status, "cal->get");
int32_t offset = tz->getOffset((uint8_t)era, year, month, day, (uint8_t)dayOfWeek, millis, status);
int32_t raw_offset = tz->getRawOffset();
if (offset == raw_offset)
dataerrln("Offsets should match");
delete cal;
}
示例2: return
UBool
TimeZone::hasSameRules(const TimeZone& other) const
{
return (getRawOffset() == other.getRawOffset() &&
useDaylightTime() == other.useDaylightTime());
}
示例3: 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;
}