[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: KDateTime: next iteration
From: David Jarvie <lists () astrojar ! org ! uk>
Date: 2005-11-28 19:24:32
Message-ID: 200511281924.35324.lists () astrojar ! org ! uk
[Download RAW message or body]
I attach another iteration of the KDateTime header. The implementation file is
at http://www.astrojar.org.uk/linux/download/kdatetime.cpp. This now
incorporates all 5 types of "time zone" information which has been discussed:
UTC
Offset from UTC
Time zone
Local time zone (a special case of "Time zone")
Local clock time (no time zone)
As far as I can see, the "offset from UTC" type is adequately handled in the
KDateTime class, rather than creating a separate class for it which I can't
yet see any real use for.
I've also amended the doxygen comments, and incorporated a reference to the
W3C time zones write-up which Frans flagged up.
--
David Jarvie.
KAlarm author and maintainer.
http://www.astrojar.org.uk/linux/kalarm.html
["kdatetime.h" (text/x-c++hdr)]
/*
This file is part of the KDE libraries
Copyright (c) 2005 David Jarvie <software@astrojar.org.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
/** @file
* Date/times with associated time zone
* @author David Jarvie <software@astrojar.org.uk>.
*/
#ifndef _KDATETIME_H_
#define _KDATETIME_H_
#include <ktimezones.h>
#include "kdelibs_export.h"
class KDateTimePrivate;
/**
* @short A class representing a date and time with an associated time zone
*
* Topics:
* - @ref intro
* - @ref manipulation
* - @ref compatibility
*
* @section intro Introduction
*
* The class KDateTime combines a date and time with support for an
* associated time zone or UTC offset. When manipulating KDateTime objects,
* their time zones or UTC offsets are automatically taken into account.
*
* The time zone characteristic types which KDateTime supports are:
* - the UTC time zone
* - a local time with a specified offset from UTC
* - a local time in a specified time zone
* - a local time using the current system time zone (a special case of the
* previous item)
* - local clock time, using whatever the local system clock says on whichever
* computer it happens to be on. In this case, the equivalent UTC time will
* vary depending on system. As a result, calculations involving local clock
* times do not necessarily produce reliable results.
* These characteristics are more fully described in the description of the
* TimeSpec enumeration. Also see
* <a href="http://www.w3.org/TR/timezone/">W3C: Working with Time Zones</a>
* for a good overview of the different ways of representing times.
*
* To set the time zone characteristics, use one of the setTimeZone() methods,
* to get the time zone characteristics, call type(), isUTC(), isLocalZone(),
* isOffsetFromUTC() or isClockTime().
*
* @section manipulation Date and Time Manipulation
*
* A KDateTime object can be created by passing a date and time in its
* constructor, together with a time zone characteristic specification.
*
* If both the date and time are null, isNull() returns true. If the date, time
* and time zone characteristic are all valid, isValid() returns true.
*
* A KDateTime object can be converted to a different time zone characteristic
* by using toUTC(), toLocalZone() or toClockTime(). It can be converted to
* a specific time zone by toZone(). To return the time as an elapsed time
* since 1 January 1970 (as used by time(2)), use toTime_t().
*
* The date and time can be set either in the constructor, or afterwards by
* calling setDate(), setTime() or setDateTime(). To return the date and/or
* time components of the KDateTime, use date(), time() and dateTime().
*
* You can increment or decrement the date/time using addSecs(), addDays(),
* addMonths() and addYears(). The interval between two date/time values can
* be found using secsTo() or daysTo().
*
* The comparison operators (operator==(), operator<(), etc.) all take the time
* zone properly into account; if the two KDateTime objects have different time
* zones, they are first converted to UTC before the comparison is performed.
*
* KDateTime values may be converted to and from a string representation using
* the toString() and fromString() methods. These handle a variety of text
* formats including ISO 8601 and RFC 2822.
*
* @section compatibility QDateTime Compatibility
*
* KDateTime's interface is designed to be as compatible as possible with that
* of QDateTime, but with adjustments to cater for time zone handling. Because
* QDateTime lacks virtual methods, KDateTime is not inherited from QDateTime,
* but instead is implemented using a private QDateTime object.
*
* @see KTimezone, KSystemTimezones, QDateTime, QDate, QTime
* @see <a href="http://www.w3.org/TR/timezone/">W3C: Working with Time Zones</a>
* @author David Jarvie \<software@astrojar.org.uk\>.
* @since 4.0
*/
class KDECORE_EXPORT KDateTime
{
public:
/**
* The time zone characteristics of a KDateTime instance.
* This specifies how the date/time component of the KDateTime instance
* should be interpreted, i.e. what time zone (if any) the date/time is
* expressed in.
*/
enum TimeSpec
{
UTC, /**< a UTC time */
OffsetFromUTC, /**< a local time which has a fixed offset from UTC. */
TimeZone, /**< a time in a specified time zone. If the time zone is
* the current system time zone (i.e. that returned by
* KSystemTimezones::local()), LocalZone may be used
* instead.
*/
LocalZone, /**< a time in the current system time zone.
* When used to initialise a KDateTime instance, this is
* simply a shorthand for calling the setting method with
* a time zone parameter KSystemTimezones::local(). Note
* that if the system is changed to a different time zone
* afterwards, the KDateTime instance will still use the
* original system time zone rather than adopting the new
* zone.
* When returned by a method, it indicates that the time
* zone stored in the instance is that returned by
* KSystemTimezones::local().
*/
ClockTime /**< a clock time which ignores time zones and simply uses
* whatever the local system clock says the time is. You
* could, for example, set a wake-up time of 07:30 on
* some date, and then no matter where you were in the
* world, you would be in time for breakfast as long as
* your computer was aligned with the local time.
*
* Note that any calculations which involve clock times
* cannot be guaranteed to be accurate, since by
* definition they contain no information about time
* zones or daylight savings changes.
*/
};
/** Format for strings representing date/time values. */
enum TimeFormat
{
ISODate, /**< ISO 8601 format, i.e. YYYY-MM-DDThh:mm:ssTZ, where TZ
* is the time zone offset (blank for local time,
* Z for UTC, or ±hhmm for an offset from UTC)
*/
RFC2822Date, /**< RFC 2822 format without day of the week,
* i.e. DD Mon YYYY hh:mm:ss ±hhmm
*/
RFC2822DateDay, /**< RFC 2822 format including day of the week,
* i.e. Day, DD Mon YYYY hh:mm:ss ±hhmm
*/
QtTextDate, /**< Same format as Qt::TextDate (i.e. Day Mon DD hh:mm:ss YYYY)
* with, if not local time, the UTC offset appended
*/
LocalDate /**< Same format as Qt::LocalDate (i.e. locale dependent)
* with, if not local time, the UTC offset appended
*/
};
/**
* Constructs an invalid date/time.
*/
KDateTime();
/**
* Constructs a date/time with associated time zone. The time is
* set to 00:00:00.
*
* @param date date in the time zone @p tz
* @param tz time zone
*/
KDateTime(const QDate &date, const KTimezone *tz);
/**
* Constructs a date/time with associated time zone.
*
* @param date date in the time zone @p tz
* @param time time in the time zone @p tz
* @param tz time zone
*/
KDateTime(const QDate &date, const QTime &time, const KTimezone *tz);
/**
* Constructs a date/time with associated time zone.
* If @p dt is specified as a UTC time (i.e. @c dt.timeSpec() is @c Qt::UTC),
* it is first converted to local time in time zone @p tz before being stored.
*
* @param dt date and time
* @param tz time zone
*/
KDateTime(const QDateTime &dt, const KTimezone *tz);
/**
* Constructs a date/time expressed as specified by @p spec. The time
* component is set to 00:00:00.
*
* The instance is initialised according to the value of @p spec as follows:
* - @c UTC : date/time is stored as UTC.
* - @c OffsetFromUTC : date/time is a local time at the specified offset
* from UTC.
* - @c LocalZone : date/time is a local time in the current system time
* zone.
* - @c ClockTime : time zones are ignored.
* - Note that @c TimeZone is invalid here, and will construct an invalid
* date/time.
*
* @param date date in the time zone indicated by @p spec
* @param spec how the date/time is stored
* @param utcOffset number of seconds to add to UTC to get the local
* time. Ignored if @p spec is not @c OffsetFromUTC.
*/
explicit KDateTime(const QDate &date, TimeSpec spec = LocalZone, int utcOffset = 0);
/**
* Constructs a date/time expressed as specified by @p spec.
*
* @p date and @p time are interpreted and stored according to the value of
* @p spec as follows:
* - @c UTC : @p date and @p time are in UTC.
* - @c OffsetFromUTC : date/time is a local time at the specified offset
* from UTC.
* - @c LocalZone : @p date and @p time are local times in the current system
* time zone.
* - @c ClockTime : time zones are ignored.
* - Note that @c TimeZone is invalid here, and will construct an invalid
* date/time.
*
* @param date date in the time zone indicated by @p spec
* @param time time in the time zone indicated by @p spec
* @param spec how the date and time are stored
* @param utcOffset number of seconds to add to UTC to get the local
* time. Ignored if @p spec is not @c OffsetFromUTC.
*/
KDateTime(const QDate &date, const QTime &time, TimeSpec spec = LocalZone, int utcOffset = 0);
/**
* Constructs a date/time expressed as specified by @p spec.
*
* @p dt is interpreted and stored according to the value of @p spec as
* follows:
* - @c UTC : @p dt is stored as a UTC value. If
* @c dt.timeSpec() is @c Qt::LocalTime, @p dt is first
* converted from the current system time zone to UTC
* before storage.
* - @c OffsetFromUTC : date/time is stored as a local time at the specified
* offset from UTC. If @c dt.timeSpec() is @c Qt::UTC,
* the time is adjusted by the UTC offset before
* storage. If @c dt.timeSpec() is @c Qt::LocalTime,
* it is assumed to be a local time at the specified
* offset from UTC, and is stored without adjustment.
* - @c LocalZone : @p dt is stored as a local time in the current system
* time zone. If @c dt.timeSpec() is @c Qt::UTC, @p dt is
* first converted to local time before storage.
* - @c ClockTime : If @c dt.timeSpec() is @c Qt::UTC, @p dt is first
* converted to local time in the current system time zone
* before storage. After storage, the time is treated as a
* simple clock time, ignoring time zones.
* - Note that @c TimeZone is invalid here, and will construct an invalid
* date/time.
*
* @param dt date and time
* @param spec how the date and time are stored
* @param utcOffset number of seconds to add to UTC to get the local
* time. Ignored if @p spec is not @c OffsetFromUTC.
*/
KDateTime(const QDateTime &dt, TimeSpec spec, int utcOffset = 0);
/**
* Constructs a date/time from a QDateTime.
* The KDateTime is expressed in either UTC or the local system time zone,
* according to @p dt.timeSpec().
*
* @param dt date and time
*/
KDateTime(const QDateTime &dt);
KDateTime(const KDateTime &other);
~KDateTime();
KDateTime &operator=(const KDateTime &other);
/**
* Returns whether the date/time is null.
*
* @return @c true if both date and time are null, else @c false
* @see isValid(), QDateTime::isNull()
*/
bool isNull() const;
/**
* Returns whether the date/time is valid.
*
* @return @c true if both date and time are valid, else @c false
* @see isNull(), QDateTime::isValid()
*/
bool isValid() const;
/**
* Returns the date part of the date/time. The value returned should be
* interpreted in terms of the instance's time zone or UTC offset.
*
* @return date value
* @see time(), dateTime()
*/
QDate date() const;
/**
* Returns the time part of the date/time. The value returned should be
* interpreted in terms of the instance's time zone or UTC offset.
*
* @return time value
* @see date(), dateTime()
*/
QTime time() const;
/**
* Returns the date/time component of the instance, ignoring the time
* zone. The value returned should be interpreted in terms of the
* instance's time zone or UTC offset. The returned value's @c timeSpec()
* value will be @c Qt::UTC if the instance is a UTC time, else
* @c Qt::LocalTime.
*
* @return date/time
* @see date(), time()
*/
QDateTime dateTime() const;
/**
* Returns the time zone for the date/time. If the date/time is specified
* as a UTC time, a UTC time zone is always returned.
*
* @return time zone, or null if a local time at a fixed UTC offset or a
* local clock time
* @see isUTC(), isLocal()
*/
const KTimezone *timeZone() const;
/**
* Returns the time zone characteristics of the date/time, i.e. whether it
* is UTC, has a time zone, or is a local clock time.
*
* @return characteristic type
* @see isLocalZone(), isClockTime(), isUTC(), timeZone()
*/
TimeSpec type() const;
/**
* Returns whether the time zone for the date/time is the current local
* system time zone.
*
* @return @c true if local system time zone
* @see isUTC(), isOffsetFromUTC(), timeZone()
*/
bool isLocalZone() const;
/**
* Returns whether the date/time is a local clock time.
*
* @return @c true if local clock time
* @see isUTC(), timeZone()
*/
bool isClockTime() const;
/**
* Returns whether the date/time is a UTC time.
* It is considered to be a UTC time if it either has a UTC time zone
* characteristic (TimeSpec == UTC) or has the time zone
* KTimezones::utc().
*
* @return @c true if UTC
* @see isLocal(), isOffsetFromUTC(), timeZone()
*/
bool isUTC() const;
/**
* Returns whether the date/time is a local time at a fixed offset from
* UTC.
*
* @return @c true if local time at fixed offset from UTC
* @see isLocal(), isUTC(), UTCOffset()
*/
bool isOffsetFromUTC() const;
/**
* Returns the UTC offset associated with the date/time, if the date/time
* is a local time at a fixed offset from UTC.
*
* @return UTC offset in seconds, or 0 if not a local time at a fixed UTC
* offset
* @see isOffsetFromUTC()
*/
int UTCOffset() const;
/**
* Returns the time converted to UTC. The converted time has a UTC offset
* of zero.
* If the instance is a local clock time, it is first set to the local time
* zone, and then converted to @p zone.
*
* @return converted time
* @see toLocal(), toZone(), toTime_t(), KTimezone::convert()
*/
KDateTime toUTC() const;
/**
* Returns the time converted to the current local system time zone.
*
* @return converted time
* @see toUTC(), toZone(), KTimezone::convert()
*/
KDateTime toLocalZone() const;
/**
* Returns the time converted to the local clock time. The time is first
* converted to the local system time zone before setting its type to
* ClockTime, i.e. no associated time zone.
*
* @return converted time
* @see toLocalZone()
*/
KDateTime toClockTime() const;
/**
* Returns the time converted to a specified time zone.
* If the instance is a local clock time, it is first set to the local time
* zone, and then converted to @p zone.
*
* @param zone time zone to convert to
* @return converted time
* @see toUTC(), toLocal(), KTimezone::convert()
*/
KDateTime toZone(const KTimezone *zone) const;
/**
* Converts the time to a UTC time, measured in seconds since 00:00:00 UTC
* 1st January 1970 (as returned by time(2)).
*
* @return converted time, or -1 if the date is out of range for time_t
* @see setTime_t()
*/
uint toTime_t() const;
/**
* Sets the date part of the date/time.
*
* @param date new date value
* @see date(), setTime(), setTimeZone(), setTime_t()
*/
void setDate(const QDate &date);
/**
* Sets the time part of the date/time.
*
* @param time new time value
* @see time(), setDate(), setTimeZone(), setTime_t()
*/
void setTime(const QTime &time);
/**
* Sets the date/time part of the instance, leaving the time zone
* characteristics unaffected.
*
* If @p dt is a local time (\code dt.timeSpec() == Qt::LocalTime \endcode)
* and the instance is UTC, @p dt is first converted from the current
* system time zone to UTC before being stored. If @p dt is UTC and the
* instance is not UTC, @p dt is first converted to the current system time
* zone before being stored.
*
* @param dt date and time
*/
void setDateTime(const QDateTime &dt);
/**
* Changes the time zone characteristics of the instance to UTC, the local
* time zone or to local clock time.
*
* Any previous time zone is forgotten. The stored date/time component of
* the instance is left unchanged. Usually this method will change the
* absolute time which this instance represents.
*
* @param spec @c UTC to use UTC time zone, @c LocalZone to use the current
* local system time zone, or @c ClockTime to use local clock
* time. Note that @c TimeZone cannot be used here.
* @param utcOffset number of seconds to add to UTC to get the local
* time. Ignored if @p spec is not @c OffsetFromUTC.
* @see type(), timeZone(), setTimeZone(const KTimezone*)
*/
void setTimeZone(TimeSpec spec, int utcOffset = 0);
/**
* Sets the time zone in which the date/time is expressed.
*
* The stored date/time component of the instance is left unchanged. Usually
* this method will change the absolute time which this instance represents.
*
* To set the time zone to UTC or to local clock time, use
* setTimeZone(TimeSpec). To set the time zone to the current local system
* time zone, setTimeZone(TimeSpec) may optionally be used.
*
* @param tz new time zone
* @see timeZone(), setTimeZone(TimeSpec)
*/
void setTimeZone(const KTimezone *tz);
/**
* Returns a date/time @p secs seconds later than the stored date/time.
*
* The calculation is done in UTC to ensure that clock changes (e.g. daylight
* savings) in the time zpme do not affect the result. The result is
* expressed using the same time zone characteristics as the original
* instance.
*
* Note that if the instance is a local clock time (type @c ClockTime), any
* daylight savings changes or time zone changes during the period will
* render the result inaccurate.
*
* @return resultant date/time
* @see addDays(), addMonths(), addYears(), secsTo()
*/
KDateTime addSecs(int secs) const;
/**
* Returns a date/time @p days days later than the stored date/time.
* The result is expressed using the same time zone characteristics as the
* original instance.
*
* Note that if the instance is a local clock time (type @c ClockTime), any
* daylight savings changes or time zone changes during the period may
* render the result inaccurate.
*
* @return resultant date/time
* @see addSecs(), addMonths(), addYears(), daysTo()
*/
KDateTime addDays(int days) const;
/**
* Returns a date/time @p months months later than the stored date/time.
* The result is expressed using the same time zone characteristics as the
* original instance.
*
* Note that if the instance is a local clock time (type @c ClockTime), any
* daylight savings changes or time zone changes during the period may
* render the result inaccurate.
*
* @return resultant date/time
* @see addSecs(), addDays(), addYears(), daysTo()
*/
KDateTime addMonths(int months) const;
/**
* Returns a date/time @p years years later than the stored date/time.
* The result is expressed using the same time zone characteristics as the
* original instance.
*
* Note that if the instance is a local clock time (type @c ClockTime), any
* daylight savings changes or time zone changes during the period may
* render the result inaccurate.
*
* @return resultant date/time
* @see addSecs(), addDays(), addMonths(), daysTo()
*/
KDateTime addYears(int years) const;
/**
* Calculates the number of days from this date/time to the @p other date/time.
* In calculating the result, @p other is first converted to this instance's
* time zone. The number of days difference is then calculated ignoring
* the time parts of the two date/times. For example, if this date/time
* was 13:00 on 1 January 2000, and @p other was 02:00 on 2 January 2000,
* the result would be 1.
*
* Note that if either instance is a local clock time (type @c ClockTime),
* the result cannot be guaranteed to be accurate, since by definition they
* contain no information about time zones or daylight savings changes.
*
* @param other other date/time
* @return number of days difference
* @see secsTo(), addDays()
*/
int daysTo(const KDateTime &other) const;
/**
* Returns the number of seconds from this date/time to the @p other date/time.
*
* Before performing the comparison, the two datetimes are converted to UTC
* to ensure that the result is correct if one of the two datetimes has
* daylight saving time (DST) and the other doesn't. The only exception is
* when both instances are local clock time, in which case no conversion is
* done.
*
* Note that if either instance is a local clock time (type @c ClockTime),
* the result cannot be guaranteed to be accurate, since by definition they
* contain no information about time zones or daylight savings changes.
*
* @param other other date/time
* @return number of seconds difference
* @see addSecs(), daysTo()
*/
int secsTo(const KDateTime &other) const;
/**
* Returns the date/time as a string. The @p format parameter determines the
* format of the result string. The @p format codes used for the date and time
* components are those defined for QDateTime::toString(). For the time zone
* component, the following codes may be used:
*
* ZZZ - the abbreviated time zone code, e.g. UTC, EDT, BST.
* ZZZZ - the name of the time zone, e.g. Europe/London. This is system dependent.
* uu - the UTC offset of the time zone in hours, e.g. -02. If the offset
* is not a whole number of hours, the output is the same as for "uuu".
* uuu - the UTC offset of the time zone in hours and minutes, e.g. -0200.
* uuuu - the UTC offset of the time zone in hours and minutes, e.g. +02:00.
*
* Note that only one of these codes may be used.
*
* @param format format for the string
* @return formatted string
* @see fromString(), QDateTime::toString()
*/
QString toString(const QString &format) const;
/**
* Returns the date/time as a string, formatted according to the @p format
* parameter.
*
* @param format format for output string
* @return formatted string
* @see fromString(), QDateTime::toString()
*/
QString toString(TimeFormat format = ISODate) const;
/**
* Returns the QDateTime represented by @p string, using the @p format given.
*
* This method is the inverse of toString(TimeFormat), except that it
* can only return a UTC or local clock time. Time zone information cannot
* be returned since an offset from UTC only partially specifies a time zone.
*
* @param string string to convert
* @param format format code. LocalDate cannot be used here.
* @return QDateTime value as either a UTC or local clock time, or an
* invalid QDateTime if either parameter is invalid
* @see toString(), QString::fromString()
*/
static QDateTime fromString(const QString &string, TimeFormat format = ISODate);
/**
* Returns the QDateTime represented by @p string, using the @p format given.
* The @p format codes are the same as those for toString(), but time zone
* names (codes ZZZ and ZZZZ) are not allowed since they cannot be
* interpreted. Any UTC offset is used to adjust the resultant QDateTime. If
* a UTC offset is present, the time spec of the result will be @c Qt::UTC;
* otherwise the result will be @c Qt::LocalTime.
*
* @param string string to convert
* @param format format string
* @return QDateTime value, or an invalid QDateTime if either parameter is
* invalid
* @see toString()
*/
static QDateTime fromString(const QString &string, const QString &format);
/**
* Returns the KDateTime represented by @p string, using the @p format
* given, and using a specified time zone collection as the source of
* time zone definitions. The @p format codes are the same as those for
* toString(). Only one time zone or UTC offset code may be used.
*
* If any time zone information is present in the string, the function
* attempts to find a matching time zone in the @p zones collection. A time
* zone name (format code ZZZZ) will provide an unambiguous look up in
* @p zones. Any other type of time zone information (an abbreviated time
* zone code (ZZZ) or UTC offset (uu, uuu, uuuu) is searched for in
* @p zones and if only one time zone is found to match, the result is set
* to that zone. If more than one match is found, the action taken is
* determined by @p offsetIfAmbiguous: if @p offsetIfAmbiguous is true and
* a UTC offset is specified, a local time with an offset from UTC will be
* returned; otherwise an invalid KDateTime is returned. If the time zone
* name or abbreviation does not match any of the time zones in @p zones,
* an invalid KDateTime is returned. If the time zone UTC offset does not
* match any of the time zones in @p zones, a local time with an offset
* from UTC is returned.
*
* If no time zone information is present in the string, a local clock time
* is returned.
*
* @param string string to convert
* @param format format string
* @param zones time zone collection
* @param offsetIfAmbiguous specifies what to do if more than one zone
* matches the UTC offset found in the string
* @return KDateTime value, or an invalid KDateTime if a parameter is
* invalid, if time zone information doesn't match any in @p zones,
* or if the time zone information is ambiguous and @p offsetIfAmbiguous
* is false
* @see toString()
*/
static KDateTime fromString(const QString &string, const QString &format,
const KTimezones &zones, bool offsetIfAmbiguous = true);
/**
* Check whether this date/time is simultaneous with another.
* The comparison takes time zones into account; if the two instances have
* different time zones, they are first converted to UTC before comparing.
*
* Note that if either instance is a local clock time (type @c ClockTime),
* the result cannot be guaranteed to be correct, since by definition they
* contain no information about time zones or daylight savings changes.
*
* @return @c true if the two instances represent the same time, @c false otherwise
*/
bool operator==(const KDateTime &other) const;
bool operator!=(const KDateTime &other) const { return !(*this == other); }
/**
* Check whether this date/time is earlier than another.
* The comparison takes time zones into account; if the two instances have
* different time zones, they are first converted to UTC before comparing.
*
* Note that if either instance is a local clock time (type @c ClockTime),
* the result cannot be guaranteed to be correct, since by definition they
* contain no information about time zones or daylight savings changes.
*
* @return @c true if this instance represents an earlier time than @p other,
* @c false otherwise
*/
bool operator<(const KDateTime &other) const;
bool operator<=(const KDateTime &other) const { return !(other < *this); }
bool operator>(const KDateTime &other) const { return other < *this; }
bool operator>=(const KDateTime &other) const { return !(*this < other); }
friend QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime);
friend QDataStream & operator>>(QDataStream &in, KDateTime &dateTime);
private:
KDateTimePrivate *d;
};
#if 0
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime);
QDataStream & operator>>(QDataStream &in, KDateTime &dateTime);
#endif
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic