Ejemplo n.º 1
0
bool Recurrence::recursAt( const KDateTime &dt ) const
{
  // Convert to recurrence's time zone for date comparisons, and for more efficient time comparisons
  KDateTime dtrecur = dt.toTimeSpec( d->mStartDateTime.timeSpec() );

  // if it's excluded anyway, don't bother to check if it recurs at all.
  if ( d->mExDateTimes.containsSorted( dtrecur ) ||
       d->mExDates.containsSorted( dtrecur.date() ) ) {
    return false;
  }
  int i, end;
  for ( i = 0, end = d->mExRules.count();  i < end;  ++i ) {
    if ( d->mExRules[i]->recursAt( dtrecur ) ) {
      return false;
    }
  }

  // Check explicit recurrences, then rrules.
  if ( startDateTime() == dtrecur || d->mRDateTimes.containsSorted( dtrecur ) ) {
    return true;
  }
  for ( i = 0, end = d->mRRules.count();  i < end;  ++i ) {
    if ( d->mRRules[i]->recursAt( dtrecur ) ) {
      return true;
    }
  }

  return false;
}
Ejemplo n.º 2
0
/******************************************************************************
* Set the minimum date/time, adjusting the entered date/time if necessary.
* If 'dt' is invalid, any current minimum date/time is cleared.
*/
void AlarmTimeWidget::setMinDateTime(const KDateTime& dt)
{
	mMinDateTimeIsNow = false;
	mMinDateTime = dt.toTimeSpec(mTimeSpec);
	mDateEdit->setMinDate(mMinDateTime.date());
	setMaxMinTimeIf(KDateTime::currentDateTime(mTimeSpec));
}
Ejemplo n.º 3
0
QString Stringify::formatTime( const KDateTime &dt, bool shortfmt, const KDateTime::Spec &spec )
{
  if ( spec.isValid() ) {

    QString timeZone;
    if ( spec.timeZone() != KSystemTimeZones::local() ) {
      timeZone = ' ' + spec.timeZone().name();
    }

    return KGlobal::locale()->formatTime( dt.toTimeSpec( spec ).time(), !shortfmt ) + timeZone;
  } else {
    return KGlobal::locale()->formatTime( dt.time(), !shortfmt );
  }
}
Ejemplo n.º 4
0
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;
}
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 );
}
Ejemplo n.º 6
0
QString Stringify::formatDateTime( const KDateTime &dt, bool allDay,
                                   bool shortfmt, const KDateTime::Spec &spec )
{
  if ( allDay ) {
    return formatDate( dt, shortfmt, spec );
  }

  if ( spec.isValid() ) {
    QString timeZone;
    if ( spec.timeZone() != KSystemTimeZones::local() ) {
      timeZone = ' ' + spec.timeZone().name();
    }

    return KGlobal::locale()->formatDateTime(
      dt.toTimeSpec( spec ).dateTime(),
      ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) ) + timeZone;
  } else {
    return  KGlobal::locale()->formatDateTime(
      dt.dateTime(),
      ( shortfmt ? KLocale::ShortDate : KLocale::LongDate ) );
  }
}