KDECore
kdatetime.cpp
  
Go to the documentation of this file.
   88 static bool getNumber(const QString &string, int &offset, int mindigits, int maxdigits, int minval, int maxval, int &result);
   89 static int findString_internal(const QString &string, const char *ptr, int count, int &offset, int disp);
   96 static const int NO_NUMBER = 0x8000000;   // indicates that no number is present in string conversion functions
  109     // *** NOTE: This structure is replicated in KDateTimePrivate. Any changes must be copied there.
  213 KDateTime::Spec       KDateTime::Spec::OffsetFromUTC(int utcOffset)  { return Spec(KDateTime::OffsetFromUTC, utcOffset); }
  216 bool KDateTime::Spec::isLocalZone() const     { return d->type == KDateTime::TimeZone  &&  d->tz == KSystemTimeZones::local(); }
  219 int  KDateTime::Spec::utcOffset() const       { return d->type == KDateTime::OffsetFromUTC ? d->utcOffset : 0; }
  241         if ((d->type == KDateTime::UTC  &&  other.d->type == KDateTime::OffsetFromUTC  &&  other.d->utcOffset == 0)
  242         ||  (other.d->type == KDateTime::UTC  &&  d->type == KDateTime::OffsetFromUTC  &&  d->utcOffset == 0))
  261             s << static_cast<quint8>('z') << (spec.timeZone().isValid() ? spec.timeZone().name() : QString());
  379     void      setDt(const QDateTime &dt)     { mDt = dt; utcCached = convertedCached = m2ndOccurrence = false; }
  381     void      setDate(const QDate &d)        { mDt.setDate(d); utcCached = convertedCached = m2ndOccurrence = false; }
  382     void      setTime(const QTime &t)        { mDt.setTime(t); utcCached = convertedCached = mDateOnly = m2ndOccurrence = false; }
  383     void      setDtTimeSpec(Qt::TimeSpec s)  { mDt.setTimeSpec(s); utcCached = convertedCached = m2ndOccurrence = false; }
  389     void      newToZone(KDateTimePrivate *newd, const KTimeZone &zone, const KTimeZone &local = KTimeZone()) const;
  446                                        // if specType == ClockTime, the local time zone used to calculate the cached UTC time (mutable)
  448     mutable struct ut {                // cached UTC equivalent of 'mDt'. Saves space compared to storing QDateTime.
  459     KDateTime::SpecType   specType          : 4; // time spec type (N.B. need 3 bits + sign bit, since enums are signed on some platforms)
  531     setDtTimeSpec((specType == KDateTime::UTC) ? Qt::UTC : Qt::LocalTime);  // this clears cached UTC value
  741 void KDateTimePrivate::newToZone(KDateTimePrivate *newd, const KTimeZone &zone, const KTimeZone &local) const
  773 K_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<KDateTimePrivate>, emptyDateTimePrivate, (new KDateTimePrivate))
  833 bool      KDateTime::isLocalZone() const        { return d->specType == TimeZone  &&  d->specZone == KSystemTimeZones::local(); }
  835 bool      KDateTime::isUtc() const              { return d->specType == UTC || (d->specType == OffsetFromUTC && d->specUtcOffset == 0); }
  837 bool      KDateTime::isSecondOccurrence() const { return d->specType == TimeZone && d->secondOccurrence(); }
 1124         qdt.setTimeSpec(Qt::UTC);    // set time as UTC to avoid daylight savings adjustments in addSecs()
 1293     const bool conv = (!d->equalSpec(*other.d) || d->secondOccurrence() != other.d->secondOccurrence());
 1756                     result += (locale && locale->decimalSymbol() == QLatin1String(".")) ? QLatin1Char('.') : QLatin1Char(',');
 1822             QRegExp rx(QString::fromLatin1("^(?:([A-Z][a-z]+),\\s*)?(\\d{1,2})(\\s+|-)([^-\\s]+)(\\s+|-)(\\d{2,4})\\s+(\\d\\d):(\\d\\d)(?::(\\d\\d))?\\s+(\\S+)$"));
 1836                 rx = QRegExp(QString::fromLatin1("^([A-Z][a-z]+)\\s+(\\S+)\\s+(\\d\\d)\\s+(\\d\\d):(\\d\\d):(\\d\\d)\\s+(\\d\\d\\d\\d)$"));
 1873                     for (dayOfWeek = 0;  dayOfWeek < 7  &&  QLatin1String(longDay[dayOfWeek]) != parts[nwday];  ++dayOfWeek) ;
 1933             QDate qdate = checkDate(year, month+1, day, invalid);   // convert date, and check for out-of-range
 1963             QRegExp rx(QString::fromLatin1("^(\\d{4})-(\\d\\d)-(\\d\\d)[Tt](\\d\\d):(\\d\\d):(\\d\\d)(?:\\.(\\d+))?([Zz]|([+-])(\\d\\d):(\\d\\d))$"));
 2046             QRegExp rx(QString::fromLatin1("^([+-])?(\\d{4,})-(\\d\\d\\d|\\d\\d-\\d\\d)[T ](\\d\\d)(?::(\\d\\d)(?::(\\d\\d)(?:(?:\\.|,)(\\d+))?)?)?(Z|([+-])(\\d\\d)(?::(\\d\\d))?)?$"));
 2050                 rx = QRegExp(QString::fromLatin1("^([+-])?(\\d{4,})(\\d{4})[T ](\\d\\d)(?:(\\d\\d)(?:(\\d\\d)(?:(?:\\.|,)(\\d+))?)?)?(Z|([+-])(\\d\\d)(\\d\\d)?)?$"));
 2053                     rx = QRegExp(QString::fromLatin1("^([+-])?(\\d{4})(\\d{3})[T ](\\d\\d)(?:(\\d\\d)(?:(\\d\\d)(?:(?:\\.|,)(\\d+))?)?)?(Z|([+-])(\\d\\d)(\\d\\d)?)?$"));
 2123                 d = checkDate(year, 1, 1, invalid).addDays(day - 1);   // convert date, and check for out-of-range
 2209             QRegExp rx(QString::fromLatin1("^(\\S+\\s+\\S+\\s+\\d\\d\\s+(\\d\\d:\\d\\d:\\d\\d\\s+)?\\d\\d\\d\\d)\\s*(.*)$"));
 2800     QDate d = checkDate(year, month, (day > 0 ? day : 1), status);   // convert date, and check for out-of-range
 2819     dateOnly = (hour == NO_NUMBER && minute == NO_NUMBER && second == NO_NUMBER && millisec == NO_NUMBER);
 2838     QDateTime dt(d, QTime(hour, minute, second, millisec), (tzoffset == 0 ? Qt::UTC : Qt::LocalTime));
 3015 bool getNumber(const QString& string, int& offset, int mindigits, int maxdigits, int minval, int maxval, int& result)
 3034     if (!ok  ||  (result != NO_NUMBER && n != result)  ||  (minval != NO_NUMBER && n < minval)  ||  (n > maxval && maxval >= 0))
 3041 int findString_internal(const QString &string, const char *array, int count, int &offset, int disp)
QDataStream & operator<<(QDataStream &s, const KDateTime::Spec &spec)
Write spec to the datastream out, in binary format. 
Definition: kdatetime.cpp:248
int daysTo(const KDateTime &other) const 
Calculates the number of days from this date/time to the other date/time. 
Definition: kdatetime.cpp:1195
static bool isSimulated()
Check whether there is a simulated local system time zone. 
Definition: ksystemtimezone.cpp:219
KDateTime toTimeSpec(const Spec &spec) const 
Returns the time converted to a new time specification. 
Definition: kdatetime.cpp:984
friend QDataStream & operator>>(QDataStream &in, KDateTime &dateTime)
Read a KDateTime object into dateTime from in, in binary format. 
Definition: kdatetime.cpp:2456
QString toString() const 
Finalizes the translation, creates QString with placeholders substituted. 
Definition: klocalizedstring.cpp:192
This KDateTime starts after the start of the other, and ends before the end of the other...
Definition: kdatetime.h:487
static int matchMonth(const QString &string, int &offset, KCalendarSystem *)
Definition: kdatetime.cpp:2892
Date/times with associated time zone. 
static KDateTime currentLocalDateTime()
Returns the current date and time, as reported by the system clock, expressed in the local system tim...
Definition: kdatetime.cpp:1231
qint64 secsTo_long(const KDateTime &other) const 
Returns the number of seconds from this date/time to the other date/time. 
Definition: kdatetime.cpp:1164
virtual QString monthName(int month, int year, MonthNameFormat format=LongName) const =0
Gets specific calendar type month name for a given month number If an invalid month is specified...
Definition: kcalendarsystem.cpp:1842
static KTimeZone zone(const QString &name)
Returns the time zone with the given name. 
Definition: ksystemtimezone.cpp:255
static QDate checkDate(int year, int month, int day, Status &)
Definition: kdatetime.cpp:3060
KLocalizedString ki18n(const char *msg)
Creates localized string from a given message. 
Definition: klocalizedstring.cpp:924
Spec timeSpec() const 
Returns the time specification of the date/time, i.e. 
Definition: kdatetime.cpp:842
KDateTime addDays(int days) const 
Returns a date/time days days later than the stored date/time. 
Definition: kdatetime.cpp:1132
void setTimeSpec(const Spec &spec)
Changes the time specification of the instance. 
Definition: kdatetime.cpp:1050
static void setSimulatedSystemTime(const KDateTime &newTime)
Set an adjustment to be applied when fetching the current system time. 
Definition: kdatetime.cpp:2424
Comparison compare(const KDateTime &other) const 
Compare this instance with another to determine whether they are simultaneous, earlier or later...
Definition: kdatetime.cpp:1290
KDateTime toOffsetFromUtc() const 
Returns the time expressed as an offset from UTC, using the UTC offset associated with this instance'...
Definition: kdatetime.cpp:885
static KDateTime fromString(const QString &string, TimeFormat format=ISODate, bool *negZero=0)
Returns the KDateTime represented by string, using the format given. 
Definition: kdatetime.cpp:1801
QString toString(const QString &format) const 
Returns the date/time as a string. 
Definition: kdatetime.cpp:1434
bool isOffsetFromUtc() const 
Returns whether the time specification is a local time at a fixed offset from UTC. 
Definition: kdatetime.cpp:218
QDateTime toZoneTime(const QDateTime &utcDateTime, bool *secondOccurrence=0) const 
Converts a UTC date/time into local time in this time zone. 
Definition: ktimezone.cpp:808
void setSecondOccurrence(bool second)
Sets whether the date/time is the second occurrence of this time. 
Definition: kdatetime.cpp:1055
bool isDateOnly() const 
Returns whether the instance represents a date/time or a date-only value. 
Definition: kdatetime.cpp:832
static KDateTime realCurrentLocalDateTime()
Return the real (not simulated) system time. 
Definition: kdatetime.cpp:2441
static void setLocalZone(const KTimeZone &tz)
Set or clear the simulated local system time zone. 
Definition: ksystemtimezone.cpp:211
The KTimeZones class represents a time zone database which consists of a collection of individual tim...
Definition: ktimezone.h:308
bool isClockTime() const 
Returns whether the time specification is a local clock time. 
Definition: kdatetime.cpp:217
QString decimalSymbol() const 
Returns what a decimal point should look like ("." or "," etc.) according to the current locale or us...
Definition: klocale.cpp:252
K_GLOBAL_STATIC_WITH_ARGS(KComponentData, fakeComponent,(KGlobalPrivate::initFakeComponent())) KStandardDirs *KGlobal
Definition: kglobal.cpp:128
bool equivalentTo(const Spec &other) const 
Checks whether this instance is equivalent to another. 
Definition: kdatetime.cpp:230
KCalendarSystem abstract base class, provides support for local Calendar Systems in KDE...
Definition: kcalendarsystem.h:40
void setDateOnly(bool dateOnly)
Sets the instance either to being a date and time value, or a date-only value. 
Definition: kdatetime.cpp:1020
KTimeZone timeZone() const 
Returns the time zone for the date/time, according to the time specification type as follows: ...
Definition: kdatetime.cpp:193
bool outOfRange() const 
Checks whether the date/time returned by the last call to fromString() was invalid because an otherwi...
Definition: kdatetime.cpp:831
uint toTime_t() const 
Converts the time to a UTC time, measured in seconds since 00:00:00 UTC 1st January 1970 (as returned...
Definition: kdatetime.cpp:1001
bool isOffsetFromUtc() const 
Returns whether the date/time is a local time at a fixed offset from UTC. 
Definition: kdatetime.cpp:836
void setTime_t(qint64 seconds)
Sets the time to a UTC time, specified as seconds since 00:00:00 UTC 1st January 1970 (as returned by...
Definition: kdatetime.cpp:1009
bool operator==(const KDateTime &other) const 
Check whether this date/time is simultaneous with another. 
Definition: kdatetime.cpp:1360
int utcOffset() const 
Returns the UTC offset associated with the time specification. 
Definition: kdatetime.cpp:219
System time zone functions. 
KDateTime addMSecs(qint64 msecs) const 
Returns a date/time msecs milliseconds later than the stored date/time. 
Definition: kdatetime.cpp:1070
int utcOffset() const 
Returns the UTC offset associated with the date/time. 
Definition: kdatetime.cpp:858
static int getAmPm(const QString &string, int &offset, KLocale *)
Definition: kdatetime.cpp:2975
static bool getNumber(const QString &string, int &offset, int mindigits, int maxdigits, int minval, int maxval, int &result)
Definition: kdatetime.cpp:3015
bool isClockTime() const 
Returns whether the date/time is a local clock time. 
Definition: kdatetime.cpp:834
QByteArray abbreviation(const QDateTime &utcDateTime) const 
Returns the time zone abbreviation current at a specified time. 
Definition: ktimezone.cpp:681
static int findString_internal(const QString &string, const char *ptr, int count, int &offset, int disp)
Definition: kdatetime.cpp:3041
static void setFromStringDefault(const Spec &spec)
Sets the default time specification for use by fromString() when no time zone or UTC offset is found ...
Definition: kdatetime.cpp:2419
QDateTime dateTime() const 
Returns the date/time component of the instance, ignoring the time zone. 
Definition: kdatetime.cpp:840
static KTimeZone local()
Returns the current local system time zone. 
Definition: ksystemtimezone.cpp:195
static Spec OffsetFromUTC(int utcOffset)
Returns a UTC offset time specification. 
Definition: kdatetime.cpp:213
a clock time which ignores time zones and simply uses whatever the local system clock says the time i...
Definition: kdatetime.h:203
KDateTime toClockTime() const 
Returns the time converted to the local clock time. 
Definition: kdatetime.cpp:953
int secsTo(const KDateTime &other) const 
Returns the number of seconds from this date/time to the other date/time. 
Definition: kdatetime.cpp:1159
KDateTime addYears(int years) const 
Returns a date/time years years later than the stored date/time. 
Definition: kdatetime.cpp:1150
QDateTime toUtc(const QDateTime &zoneDateTime) const 
Converts a date/time, which is interpreted as local time in this time zone, into UTC. 
Definition: ktimezone.cpp:796
static QTime currentLocalTime()
Returns the current time of day in the local time zone, as reported by the system clock...
Definition: kdatetime.cpp:1285
static KDateTime currentDateTime(const Spec &spec)
Returns the current date and time, as reported by the system clock, expressed in a given time specifi...
Definition: kdatetime.cpp:1262
virtual QString monthName(int month, int year, MonthNameFormat format=LongName) const 
Gets specific calendar type month name for a given month number If an invalid month is specified...
Definition: kcalendarsystemqdate.cpp:499
KDateTime addSecs(qint64 secs) const 
Returns a date/time secs seconds later than the stored date/time. 
Definition: kdatetime.cpp:1107
static int matchDay(const QString &string, int &offset, KCalendarSystem *)
Definition: kdatetime.cpp:2851
A class representing a date and time with an associated time zone. 
Definition: kdatetime.h:171
static KTimeZone realLocalZone()
Return the real (not simulated) local system time zone. 
Definition: ksystemtimezone.cpp:205
static QDate currentLocalDate()
Returns the current date in the local time zone, as reported by the system clock. ...
Definition: kdatetime.cpp:1280
KDateTime toLocalZone() const 
Returns the time converted to the current local system time zone. 
Definition: kdatetime.cpp:927
bool isLocalZone() const 
Returns whether the time specification is the current local system time zone. 
Definition: kdatetime.cpp:216
KLocale provides support for country specific stuff like the national language. 
Definition: klocale.h:69
static QDateTime fromStr(const QString &string, const QString &format, int &utcOffset, QString &zoneName, QByteArray &zoneAbbrev, bool &dateOnly, Status &)
Definition: kdatetime.cpp:2477
friend QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
Write dateTime to the datastream out, in binary format. 
Definition: kdatetime.cpp:2450
KDateTime addMonths(int months) const 
Returns a date/time months months later than the stored date/time. 
Definition: kdatetime.cpp:1141
This KDateTime starts after the start of the other, and ends at the same time as the other...
Definition: kdatetime.h:491
void detach()
Create a separate copy of this instance's data if it is implicitly shared with another instance...
Definition: kdatetime.cpp:828
bool isLocalZone() const 
Returns whether the time zone for the date/time is the current local system time zone. 
Definition: kdatetime.cpp:833
QDataStream & operator>>(QDataStream &s, KDateTime::Spec &spec)
Read a KDateTime::Spec object into spec from in, in binary format. 
Definition: kdatetime.cpp:274
This KDateTime is strictly earlier than the other, i.e. 
Definition: kdatetime.h:480
void setType(SpecType type, int utcOffset=0)
Initialises the time specification. 
Definition: kdatetime.cpp:158
This KDateTime starts before the start of the other, and ends after the end of the other...
Definition: kdatetime.h:501
KDateTime toZone(const KTimeZone &zone) const 
Returns the time converted to a specified time zone. 
Definition: kdatetime.cpp:966
void setDateTime(const QDateTime &dt)
Sets the date/time part of the instance, leaving the time specification unaffected. 
Definition: kdatetime.cpp:1035
This KDateTime starts at the same time as the other, and ends before the end of the other...
Definition: kdatetime.h:483
QMap< QString, KTimeZone > ZoneMap
Map of KTimeZone instances, indexed by time zone name. 
Definition: ktimezone.h:323
Definition: kdatetime.cpp:78
Definition: kdatetime.cpp:77
static KDateTime currentUtcDateTime()
Returns the current date and time, as reported by the system clock, expressed in UTC. 
Definition: kdatetime.cpp:1240
static bool getUTCOffset(const QString &string, int &offset, bool colon, int &result)
Definition: kdatetime.cpp:2930
const ZoneMap zones() const 
Returns all the time zones defined in this collection. 
Definition: ktimezone.cpp:67
virtual int offsetAtZoneTime(const QDateTime &zoneDateTime, int *secondOffset=0) const 
Returns the offset of this time zone to UTC at the given local date/time. 
Definition: ktimezone.cpp:865
Definition: kcalendarsystemqdate_p.h:41
SpecType timeType() const 
Returns the time specification type of the date/time, i.e. 
Definition: kdatetime.cpp:843
virtual QString weekDayName(int weekDay, WeekDayNameFormat format=LongDayName) const 
Gets specific calendar type week day name. 
Definition: kcalendarsystemqdate.cpp:509
static KTimeZone utc()
Returns a standard UTC time zone, with name "UTC". 
Definition: ktimezone.cpp:911
virtual QString weekDayName(int weekDay, WeekDayNameFormat format=LongDayName) const =0
Gets specific calendar type week day name. 
Definition: kcalendarsystem.cpp:1881
bool isSecondOccurrence() const 
Returns whether the date/time is the second occurrence of this time. 
Definition: kdatetime.cpp:837
bool operator<(const KDateTime &other) const 
Check whether this date/time is earlier than another. 
Definition: kdatetime.cpp:1392
bool isUtc() const 
Returns whether the time specification is a UTC time. 
Definition: kdatetime.cpp:202
KTimeZone zone(const QString &name) const 
Returns the time zone with the given name. 
Definition: ktimezone.cpp:118
static int findString(const QString &string, const char array[][disp], int count, int &offset)
Definition: kdatetime.cpp:91
static int indexOf(const QByteArray &that, const QByteArray &ba)
Definition: kmimemagicrule.cpp:60
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
            Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.
    KDE API Reference