本文整理汇总了C++中KDateTime::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ KDateTime::toString方法的具体用法?C++ KDateTime::toString怎么用?C++ KDateTime::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDateTime
的用法示例。
在下文中一共展示了KDateTime::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDateString
QString DateStringBuilder::getDateString(const KDateTime &dateTime, bool grouped)
{
if (!dateTime.isValid() || dateTime.isNull()) {
return QString();
}
QString day;
if (QDateTime().currentDateTime().date() == dateTime.date()) {
day = i18nc( "today", "Today" );
}
if (QDateTime().currentDateTime().date().addDays(1) == dateTime.date()) {
day = i18nc( "tomorrow", "Tomorrow" );
}
if (QDateTime().currentDateTime().date() == dateTime.date().addDays(1)) {
day = i18nc( "yesterday", "Yesterday" );
}
if (!grouped && !day.isEmpty()) {
return day.append("/t").append(dateTime.toString("%d.%m.%Y"));
}
if (!grouped && day.isEmpty()) {
return dateTime.toString("%:a %d.%m.%Y");
}
if (QDateTime().currentDateTime().date().weekNumber() == dateTime.date().weekNumber()) {
return dateTime.toString("%A");
}
//TODO last week
return dateTime.toString("%B");
//KGlobal::locale()->formatDate(pimitem->getPrimaryDate().dateTime());
//return pimitem->getPrimaryDate().dateTime().toString("ddd dd.MM hh:mm");
//return dateTime.toString("%:a %d.%m.%Y");
}
示例2: mHandlersCount
FreeBusyManagerPrivate::FreeBusyProvidersRequestsQueue::FreeBusyProvidersRequestsQueue(
const KDateTime &start, const KDateTime &end )
: mHandlersCount( 0 ), mResultingFreeBusy( 0 )
{
mStartTime = start.toString();
mEndTime = end.toString();
mResultingFreeBusy = KCalCore::FreeBusy::Ptr( new KCalCore::FreeBusy( start, end ) );
}
示例3: engineError
void KdeObservatory::engineError(const QString &source, const QString &error)
{
kDebug() << "Source:" << source << "Error:" << error;
if (source == "fatal" && m_sourceCounter > 0)
{
m_viewTransitionTimer->stop();
foreach(QGraphicsWidget *widget, m_views)
widget->hide();
m_views.clear();
graphicsWidget();
m_updateLabel->setStyleSheet(QString("QLabel{color:rgb(255, 0, 0);}"));
m_updateLabel->setText(error);
setBusy(false);
return;
}
--m_sourceCounter;
if (m_sourceCounter == 0)
{
KDateTime currentTime = KDateTime::currentLocalDateTime();
KLocale *locale = KGlobal::locale();
m_updateLabel->setStyleSheet(QString("QLabel{color:rgb(0, 0, 0);}"));
m_updateLabel->setText(i18n("Last update: %1 %2", currentTime.toString(locale->dateFormatShort()), currentTime.toString(locale->timeFormat())));
setBusy(false);
updateViews();
}
}
示例4: dataUpdated
void KdeObservatory::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
{
// Prevent for being updated from another instance update request
if (data["appletId"].toUInt() != id())
return;
QString project = data["project"].toString();
if (sourceName != "topActiveProjects" && !data.contains(project) && !data.contains("error"))
return;
if (sourceName == "topActiveProjects")
m_viewProviders[i18n("Top Active Projects")]->updateViews(data);
else if (sourceName == "topProjectDevelopers" && !project.isEmpty())
m_viewProviders[i18n("Top Developers")]->updateViews(data);
else if (sourceName == "commitHistory" && !project.isEmpty())
m_viewProviders[i18n("Commit History")]->updateViews(data);
else if (sourceName == "krazyReport" && !project.isEmpty())
m_viewProviders[i18n("Krazy Report")]->updateViews(data);
--m_sourceCounter;
m_collectorProgress->setValue(m_collectorProgress->maximum() - m_sourceCounter);
if (m_sourceCounter == 0)
{
KDateTime currentTime = KDateTime::currentLocalDateTime();
KLocale *locale = KGlobal::locale();
m_updateLabel->setStyleSheet(QString("QLabel{color:rgb(0, 0, 0);}"));
m_updateLabel->setText(i18n("Last update: %1 %2", currentTime.toString(locale->dateFormatShort()), currentTime.toString(locale->timeFormat())));
setBusy(false);
updateViews();
}
}
示例5: getGroupedDate
QString DateStringBuilder::getGroupedDate(const KDateTime &dateTime)
{
if (!dateTime.isValid() || dateTime.isNull()) {
return QString();
}
QDate currentDate = QDateTime::currentDateTime().date();
if (currentDate.weekNumber() == dateTime.date().weekNumber()) { //this week
return getDayName(dateTime);
}
if (currentDate.addDays(-7).weekNumber() == dateTime.date().weekNumber()) { //last week
return i18n("Last Week");
}
if (currentDate.year() == dateTime.date().year()) { //this year
return dateTime.toString("%B");
}
return dateTime.toString("%B %Y");
}
示例6: dumpAlarms
QStringList KOAlarmClient::dumpAlarms()
{
KDateTime start = KDateTime( QDateTime::currentDateTime().date(),
QTime( 0, 0 ), KDateTime::LocalZone );
KDateTime end = start.addDays( 1 ).addSecs( -1 );
QStringList lst;
// Don't translate, this is for debugging purposes.
lst << QString( "AlarmDeamon::dumpAlarms() from " ) + start.toString() + " to " +
end.toString();
QList<Alarm *> alarms = mCalendar->alarms( start, end );
QList<Alarm *>::ConstIterator it;
for ( it = alarms.constBegin(); it != alarms.constEnd(); ++it ) {
Alarm *a = *it;
lst << QString( " " ) + a->parent()->summary() + " (" + a->time().toString() + ')';
}
return lst;
}
示例7: getFullDateTime
QString DateStringBuilder::getFullDateTime(const KDateTime &dateTime)
{
if (!dateTime.isValid() || dateTime.isNull()) {
return QString();
}
QString date;
date.append(getFullDate(dateTime));
date.append(" ");
date.append(dateTime.toString("%k:%M:%S"));
return date;
}
示例8: getShortDate
QString DateStringBuilder::getShortDate(const KDateTime &dateTime)
{
if (!dateTime.isValid() || dateTime.isNull()) {
return QString();
}
QDate currentDate = QDateTime().currentDateTime().date();
if (currentDate.weekNumber() == dateTime.date().weekNumber() || currentDate.addDays(1) == dateTime.date()) { //this week or tomorrow (i.e. on sunday)
return getDayName(dateTime);
}
if (currentDate.year() == dateTime.date().year()) { //this year
//Micro optimization because this function showed up as hotspot
static QCache<uint, QString> cache;
uint hash = dateTime.date().month() ^ dateTime.date().day();
if (!cache.contains(hash)) {
cache.insert(hash, new QString(dateTime.toString("%d.%m")));
}
return *cache[hash];
}
return dateTime.toString("%d.%m.%Y");
}
示例9: listRecentPosts
void GData::listRecentPosts( const QStringList &labels, int number,
const KDateTime &upMinTime, const KDateTime &upMaxTime,
const KDateTime &pubMinTime, const KDateTime &pubMaxTime )
{
kDebug();
Q_D( GData );
QString urlString( "http://www.blogger.com/feeds/" + blogId() + "/posts/default" );
if ( ! labels.empty() ) {
urlString += "/-/" + labels.join( "/" );
}
kDebug() << "listRecentPosts()";
KUrl url( urlString );
if ( !upMinTime.isNull() ) {
url.addQueryItem( "updated-min", upMinTime.toString() );
}
if( !upMaxTime.isNull() ) {
url.addQueryItem( "updated-max", upMaxTime.toString() );
}
if( !pubMinTime.isNull() ) {
url.addQueryItem( "published-min", pubMinTime.toString() );
}
if( !pubMaxTime.isNull() ) {
url.addQueryItem( "published-max", pubMaxTime.toString() );
}
Syndication::Loader *loader = Syndication::Loader::create();
if ( number > 0 ) {
d->mListRecentPostsMap[ loader ] = number;
}
connect( loader,
SIGNAL(loadingComplete(Syndication::Loader*,Syndication::FeedPtr,Syndication::ErrorCode)),
this,
SLOT(slotListRecentPosts(Syndication::Loader*,Syndication::FeedPtr,Syndication::ErrorCode)) );
loader->loadFrom( url.url() );
}
示例10: 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);
}
示例11: getDayName
QString getDayName(const KDateTime &dateTime)
{
if (!dateTime.isValid() || dateTime.isNull()) {
return QString();
}
QString day;
if (QDateTime().currentDateTime().date() == dateTime.date()) {
return i18n("Today" );
}
if (QDateTime().currentDateTime().date().addDays(1) == dateTime.date()) {
return i18n( "Tomorrow" );
}
if (QDateTime().currentDateTime().date() == dateTime.date().addDays(1)) {
return i18n("Yesterday" );
}
return dateTime.toString("%A");
}
示例12: dumpTime
QString dumpTime( const KDateTime &dt, const KDateTime::Spec &viewSpec )
{
if ( !dt.isValid() ) {
return QString();
}
KDateTime vdt = viewSpec.isValid() ? dt.toTimeSpec( viewSpec ) : dt;
QString format;
#ifdef FLOAT_IS_DATE_ONLY
if ( vdt.isDateOnly() ) {
format = QLatin1String( "%Y-%m-%d" );
} else
#endif
format = QLatin1String( "%Y-%m-%dT%H:%M:%S" );
if ( vdt.isSecondOccurrence() ) {
format += QLatin1String( " %Z" );
}
if ( vdt.timeSpec() != KDateTime::ClockTime ) {
format += QLatin1String( " %:Z" );
}
return vdt.toString( format );
}
示例13: 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;
}
示例14: lastCacheUpdate
QString FreeBusyProviderBasePrivate::lastCacheUpdate()
{
KDateTime last = q->lastCacheUpdate();
return last.toString();
}
示例15: kDebug
//@cond PRIVATE
void FreeBusy::Private::init( const Event::List &eventList,
const KDateTime &start, const KDateTime &end )
{
int extraDays, i, x, duration;
duration = start.daysTo( end );
QDate day;
KDateTime tmpStart;
KDateTime tmpEnd;
// Loops through every event in the calendar
Event::List::ConstIterator it;
for ( it = eventList.constBegin(); it != eventList.constEnd(); ++it ) {
Event::Ptr event = *it;
// If this event is transparent it shouldn't be in the freebusy list.
if ( event->transparency() == Event::Transparent ) {
continue;
}
// The code below can not handle all-day events. Fixing this resulted
// in a lot of duplicated code. Instead, make a copy of the event and
// set the period to the full day(s). This trick works for recurring,
// multiday, and single day all-day events.
Event::Ptr allDayEvent;
if ( event->allDay() ) {
// addDay event. Do the hack
kDebug() << "All-day event";
allDayEvent = Event::Ptr( new Event( *event ) );
// Set the start and end times to be on midnight
KDateTime st = allDayEvent->dtStart();
st.setTime( QTime( 0, 0 ) );
KDateTime nd = allDayEvent->dtEnd();
nd.setTime( QTime( 23, 59, 59, 999 ) );
allDayEvent->setAllDay( false );
allDayEvent->setDtStart( st );
allDayEvent->setDtEnd( nd );
kDebug() << "Use:" << st.toString() << "to" << nd.toString();
// Finally, use this event for the setting below
event = allDayEvent;
}
// This whole for loop is for recurring events, it loops through
// each of the days of the freebusy request
for ( i = 0; i <= duration; ++i ) {
day = start.addDays( i ).date();
tmpStart.setDate( day );
tmpEnd.setDate( day );
if ( event->recurs() ) {
if ( event->isMultiDay() ) {
// FIXME: This doesn't work for sub-daily recurrences or recurrences with
// a different time than the original event.
extraDays = event->dtStart().daysTo( event->dtEnd() );
for ( x = 0; x <= extraDays; ++x ) {
if ( event->recursOn( day.addDays( -x ), start.timeSpec() ) ) {
tmpStart.setDate( day.addDays( -x ) );
tmpStart.setTime( event->dtStart().time() );
tmpEnd = event->duration().end( tmpStart );
addLocalPeriod( q, tmpStart, tmpEnd );
break;
}
}
} else {
if ( event->recursOn( day, start.timeSpec() ) ) {
tmpStart.setTime( event->dtStart().time() );
tmpEnd.setTime( event->dtEnd().time() );
addLocalPeriod ( q, tmpStart, tmpEnd );
}
}
}
}
// Non-recurring events
addLocalPeriod( q, event->dtStart(), event->dtEnd() );
}
q->sortList();
}