本文整理汇总了C++中KDateTime::secsTo方法的典型用法代码示例。如果您正苦于以下问题:C++ KDateTime::secsTo方法的具体用法?C++ KDateTime::secsTo怎么用?C++ KDateTime::secsTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDateTime
的用法示例。
在下文中一共展示了KDateTime::secsTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: openedString
//! @return "opened x minutes ago" string or similar
static QString openedString(const QDateTime& _opened)
{
const KDateTime cur(KDateTime::currentUtcDateTime());
const KDateTime opened = KDateTime(_opened);
if (!opened.isValid() || opened >= cur)
return QString();
const int days = opened.daysTo(cur);
if (days <= 1 && opened.secsTo(cur) < 24*60*60) {
const int minutes = opened.secsTo(cur) / 60;
const int hours = minutes / 60;
if (hours < 1) {
if (minutes == 0)
return i18n("Opened less than minute ago");
else
return i18np("Opened 1 minute ago", "Opened %1 minutes ago", minutes);
} else {
return i18np("Opened 1 hour ago", "Opened %1 hours ago", hours);
}
} else {
if (days < 30)
return i18np("Opened yesterday", "Opened %1 days ago", days);
if (days < 365)
return i18np("Opened over a month ago", "Opened %1 months ago", days / 30);
return i18np("Opened one year ago", "Opened %1 years ago", days / 365);
}
return QString();
}
示例2: eventsForDate
//.........这里部分代码省略.........
if ( ( sD.month() == currentDate.month() ) &&
( sD.day() == currentDate.day() ) ) {
str = i18nc( "the appointment is today", "Today" );
summaryEvent->makeBold = true;
} else if ( ( sD.month() == currentDate.addDays( 1 ).month() ) &&
( sD.day() == currentDate.addDays( 1 ).day() ) ) {
str = i18nc( "the appointment is tomorrow", "Tomorrow" );
} else {
str = KGlobal::locale()->formatDate( sD, KLocale::FancyLongDate );
}
summaryEvent->startDate = str;
// Print the date span for multiday, floating events, for the
// first day of the event only.
if ( ev->isMultiDay() && ev->allDay() && firstDayOfMultiday && span > 1 ) {
str = IncidenceFormatter::dateToString( ev->dtStart(), false, spec ) +
" -\n " +
IncidenceFormatter::dateToString( ev->dtEnd(), false, spec );
}
summaryEvent->dateSpan = str;
// Days to go label
str = "";
dateDiff( startOfMultiday, daysTo );
if ( ev->isMultiDay() && !ev->allDay() ) {
dateDiff( date, daysTo );
}
if ( daysTo > 0 ) {
str = i18np( "in 1 day", "in %1 days", daysTo );
} else {
if ( !ev->allDay() ) {
int secs;
if ( !ev->recurs() ) {
secs = currentDateTime.secsTo( ev->dtStart() );
} else {
KDateTime kdt( date, QTime( 0, 0, 0 ), KSystemTimeZones::local() );
kdt = kdt.addSecs( -1 );
KDateTime next = ev->recurrence()->getNextDateTime( kdt );
secs = currentDateTime.secsTo( next );
}
if ( secs > 0 ) {
str = i18nc( "eg. in 1 hour 2 minutes", "in " );
int hours = secs / 3600;
if ( hours > 0 ) {
str += i18ncp( "use abbreviation for hour to keep the text short",
"1 hr", "%1 hrs", hours );
str += ' ';
secs -= ( hours * 3600 );
}
int mins = secs / 60;
if ( mins > 0 ) {
str += i18ncp( "use abbreviation for minute to keep the text short",
"1 min", "%1 mins", mins );
}
} else {
str = i18n( "now" );
}
} else {
str = i18n( "all day" );
}
}
summaryEvent->daysToGo = str;
// Summary label
str = ev->richSummary();
if ( ev->isMultiDay() && !ev->allDay() ) {