本文整理汇总了C++中KDateTime::setTimeSpec方法的典型用法代码示例。如果您正苦于以下问题:C++ KDateTime::setTimeSpec方法的具体用法?C++ KDateTime::setTimeSpec怎么用?C++ KDateTime::setTimeSpec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDateTime
的用法示例。
在下文中一共展示了KDateTime::setTimeSpec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shouldPopulateCommittedAtCorrectly
void shouldPopulateCommittedAtCorrectly() {
QStringList rawData;
rawData << "tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904";
rawData << "parent abffc0ae9ba476fe1e9a30fa2c8903113dbadb3d";
rawData << "author Me 1234567890 -0230";
rawData << "committer You 1234567890 -0230";
rawData << "";
rawData << "Some message.";
rawData << "";
commit->fillFromString(rawData.join("\n"));
KDateTime committedAt;
committedAt.setTime_t(1234567890);
committedAt.setTimeSpec(KDateTime::Spec(KDateTime::OffsetFromUTC, -9000/*==2,5h*/));
QCOMPARE(commit->committedAt().toString(), committedAt.toString());
QCOMPARE(commit->committedAt().utcOffset(), -9000);
}
示例2: VEventDateTimeToKDateTime
static KDateTime VEventDateTimeToKDateTime(const QString &s, KDateTime::Spec &tz)
{
kDebug(30015) << "top... tz.offset:" << tz.timeZone().currentOffset();
if (s.endsWith('Z')) {
tz = KSystemTimeZones::zone("UTC");
kDebug(30015) << "tz.offset:" << tz.timeZone().currentOffset();
kDebug(30015) << "new date string:" << s;
}
KDateTime ret = KDateTime::fromString(s, "yyyyMMddTHHmmss");
if (!ret.isValid()) {
// "2003-01-08T13:00:00"
kDebug(30015) << "parsing dateThh:mm format...from input:" << s;
ret = KDateTime::fromString(s, KDateTime::ISODate);
}
//
// Parsed as UTC, must now adjust for given timezone
//
if (ret.isValid() && tz.timeZone().currentOffset()) {
ret.setTimeSpec(tz);
}
//
// convert to local tz for ease of editing.
//
ret = ret.toLocalZone();
tz = KSystemTimeZones::local();
kDebug(30015) << "date string:" << s << "\n"
<< " is valid:" << ret.isValid() << "\n"
<< " parsed:" << ret.toString() << "\n"
<< " time.tz.offset:" << ret.timeZone().currentOffset()
<< " tz.offset:" << tz.timeZone().currentOffset();
return ret;
}