本文整理汇总了C++中KDateTime::toLocalZone方法的典型用法代码示例。如果您正苦于以下问题:C++ KDateTime::toLocalZone方法的具体用法?C++ KDateTime::toLocalZone怎么用?C++ KDateTime::toLocalZone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDateTime
的用法示例。
在下文中一共展示了KDateTime::toLocalZone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refresh
void NemoCalendarEventQuery::refresh()
{
if (!mIsComplete)
return;
mKCal::ExtendedCalendar::Ptr calendar = NemoCalendarDb::calendar();
KCalCore::Event::Ptr event = mUid.isEmpty()?KCalCore::Event::Ptr():calendar->event(mUid);
if (event) {
if (mOccurrence) {
delete mOccurrence;
mOccurrence = 0;
}
mKCal::ExtendedCalendar::ExpandedIncidenceValidity eiv = {
event->dtStart().toLocalZone().dateTime(),
event->dtEnd().toLocalZone().dateTime()
};
if (!mStartTime.isNull() && event->recurs()) {
KDateTime startTime = KDateTime(mStartTime, KDateTime::Spec(KDateTime::LocalZone));
KCalCore::Recurrence *recurrence = event->recurrence();
if (recurrence->recursAt(startTime)) {
eiv.dtStart = startTime.toLocalZone().dateTime();
eiv.dtEnd = KCalCore::Duration(event->dtStart(), event->dtEnd()).end(startTime).toLocalZone().dateTime();
} else {
KDateTime match = recurrence->getNextDateTime(startTime);
if (match.isNull())
match = recurrence->getPreviousDateTime(startTime);
if (!match.isNull()) {
eiv.dtStart = match.toLocalZone().dateTime();
eiv.dtEnd = KCalCore::Duration(event->dtStart(), event->dtEnd()).end(match).toLocalZone().dateTime();
}
}
}
mOccurrence = new NemoCalendarEventOccurrence(qMakePair(eiv, event.dynamicCast<KCalCore::Incidence>()),
this);
emit occurrenceChanged();
emit eventChanged();
} else {
if (mOccurrence) {
delete mOccurrence;
mOccurrence = 0;
emit occurrenceChanged();
emit eventChanged();
}
}
}
示例2: triggerDateForIncidence
/** static */
KDateTime AlarmDialog::triggerDateForIncidence( const Incidence::Ptr &incidence,
const QDateTime &reminderAt,
QString &displayStr )
{
KDateTime result;
if ( incidence->alarms().isEmpty() ) {
return result;
}
Alarm::Ptr alarm = incidence->alarms().first();
if ( incidence->recurs() ) {
result = incidence->recurrence()->getNextDateTime(
KDateTime( reminderAt, KDateTime::Spec::LocalZone( ) ) );
displayStr = KGlobal::locale()->formatDateTime( result.toLocalZone() );
}
if ( !result.isValid() ) {
result = incidence->dateTime( Incidence::RoleAlarm );
displayStr = IncidenceFormatter::dateTimeToString( result, false,
true,
KDateTime::Spec::LocalZone() );
}
return result;
}
示例3: fromString
DateTime DateTime::fromString( const QString dts, const KDateTime::Spec &spec )
{
if (dts.isEmpty()) {
return DateTime();
}
KDateTime dt = KDateTime::fromString(dts);
if ( ! dt.isValid() ) {
// try to parse in qt default format (used in early version)
dt = KDateTime( QDateTime::fromString(dts), spec ).toLocalZone();
return dt.dateTime();
}
if ( dt.isClockTime() ) {
// timezone offset missing, set to spec
return DateTime( dt.toLocalZone().dateTime() );
}
DateTime t = DateTime( dt.toTimeSpec( spec ).toLocalZone().dateTime() );
return t;
}
示例4: 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;
}
示例5: QDateTime
DateTime::DateTime( const KDateTime &dt )
: QDateTime( dt.toLocalZone().dateTime() )
{
}