当前位置: 首页>>代码示例>>C++>>正文


C++ KDateTime::toString方法代码示例

本文整理汇总了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");
}
开发者ID:sandsmark,项目名称:zanshin,代码行数:34,代码来源:datestringbuilder.cpp

示例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 ) );
 }
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:8,代码来源:freebusymanager.cpp

示例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();
    }
}
开发者ID:fluxer,项目名称:kde-extraapps,代码行数:32,代码来源:kdeobservatory.cpp

示例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();
    }
}
开发者ID:fluxer,项目名称:kde-extraapps,代码行数:33,代码来源:kdeobservatory.cpp

示例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");
}
开发者ID:sandsmark,项目名称:zanshin,代码行数:17,代码来源:datestringbuilder.cpp

示例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;
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:20,代码来源:koalarmclient.cpp

示例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;
}
开发者ID:sandsmark,项目名称:zanshin,代码行数:11,代码来源:datestringbuilder.cpp

示例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");
}
开发者ID:sandsmark,项目名称:zanshin,代码行数:20,代码来源:datestringbuilder.cpp

示例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() );
}
开发者ID:mtux,项目名称:bilbo,代码行数:39,代码来源:gdata.cpp

示例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);
		}
开发者ID:KDE,项目名称:cocoon,代码行数:17,代码来源:CommitPopulationTest.cpp

示例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");

}
开发者ID:sandsmark,项目名称:zanshin,代码行数:18,代码来源:datestringbuilder.cpp

示例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 );
}
开发者ID:dudochkin-victor,项目名称:kcalcore,代码行数:21,代码来源:testrecurprevious.cpp

示例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;
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:36,代码来源:KoRdfCalendarEvent.cpp

示例14: lastCacheUpdate

QString FreeBusyProviderBasePrivate::lastCacheUpdate()
{
    KDateTime last = q->lastCacheUpdate();
    return last.toString();
}
开发者ID:KDE,项目名称:akonadi-calendar,代码行数:5,代码来源:freebusyproviderbase.cpp

示例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();
}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:84,代码来源:freebusy.cpp


注:本文中的KDateTime::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。