本文整理汇总了C++中TimeZone::hasSameRules方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeZone::hasSameRules方法的具体用法?C++ TimeZone::hasSameRules怎么用?C++ TimeZone::hasSameRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeZone
的用法示例。
在下文中一共展示了TimeZone::hasSameRules方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SimpleTimeZone
// test new API for JDK 1.2 8/31 putback
void
TimeZoneRegressionTest::TestJDK12API()
{
// TimeZone *pst = TimeZone::createTimeZone("PST");
// TimeZone *cst1 = TimeZone::createTimeZone("CST");
UErrorCode ec = U_ZERO_ERROR;
//d,-28800,3,1,-1,120,w,9,-1,1,120,w,60
TimeZone *pst = new SimpleTimeZone(-28800*U_MILLIS_PER_SECOND,
"PST",
3,1,-1,120*U_MILLIS_PER_MINUTE,
SimpleTimeZone::WALL_TIME,
9,-1,1,120*U_MILLIS_PER_MINUTE,
SimpleTimeZone::WALL_TIME,
60*U_MILLIS_PER_MINUTE,ec);
//d,-21600,3,1,-1,120,w,9,-1,1,120,w,60
TimeZone *cst1 = new SimpleTimeZone(-21600*U_MILLIS_PER_SECOND,
"CST",
3,1,-1,120*U_MILLIS_PER_MINUTE,
SimpleTimeZone::WALL_TIME,
9,-1,1,120*U_MILLIS_PER_MINUTE,
SimpleTimeZone::WALL_TIME,
60*U_MILLIS_PER_MINUTE,ec);
if (U_FAILURE(ec)) {
errln("FAIL: SimpleTimeZone constructor");
return;
}
SimpleTimeZone *cst = dynamic_cast<SimpleTimeZone *>(cst1);
if(pst->hasSameRules(*cst)) {
errln("FAILURE: PST and CST have same rules");
}
UErrorCode status = U_ZERO_ERROR;
int32_t offset1 = pst->getOffset(1,
1997, UCAL_OCTOBER, 26, UCAL_SUNDAY, (2*60*60*1000), status);
failure(status, "getOffset() failed");
int32_t offset2 = cst->getOffset(1,
1997, UCAL_OCTOBER, 26, UCAL_SUNDAY, (2*60*60*1000), 31, status);
failure(status, "getOffset() failed");
if(offset1 == offset2)
errln("FAILURE: Sunday Oct. 26 1997 2:00 has same offset for PST and CST");
// verify error checking
pst->getOffset(1,
1997, UCAL_FIELD_COUNT+1, 26, UCAL_SUNDAY, (2*60*60*1000), status);
if(U_SUCCESS(status))
errln("FAILURE: getOffset() succeeded with -1 for month");
status = U_ZERO_ERROR;
cst->setDSTSavings(60*60*1000, status);
failure(status, "setDSTSavings() failed");
int32_t savings = cst->getDSTSavings();
if(savings != 60*60*1000) {
errln("setDSTSavings() failed");
}
delete pst;
delete cst;
}