KAlarm Library
datetime.h
00001 /* 00002 * datetime.h - date/time with start-of-day time for date-only values 00003 * This file is part of kalarmcal library, which provides access to KAlarm 00004 * calendar data. 00005 * Copyright © 2003,2005-2007,2009,2011 by David Jarvie <djarvie@kde.org> 00006 * 00007 * This library is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU Library General Public License as published 00009 * by the Free Software Foundation; either version 2 of the License, or (at 00010 * your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, but WITHOUT 00013 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00015 * License for more details. 00016 * 00017 * You should have received a copy of the GNU Library General Public License 00018 * along with this library; see the file COPYING.LIB. If not, write to the 00019 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00020 * MA 02110-1301, USA. 00021 */ 00022 #ifndef KALARM_DATETIME_H 00023 #define KALARM_DATETIME_H 00024 00025 #include "kalarmcal_export.h" 00026 00027 #include <kdatetime.h> 00028 00029 namespace KAlarmCal 00030 { 00031 00042 class KALARMCAL_EXPORT DateTime 00043 { 00044 public: 00048 DateTime(); 00050 DateTime(const QDate& d, const KDateTime::Spec& spec); 00052 DateTime(const QDate& d, const QTime& t, const KDateTime::Spec& spec); 00054 DateTime(const QDateTime& dt, const KDateTime::Spec& spec); 00056 DateTime(const KDateTime& dt); 00058 DateTime(const DateTime& dt); 00059 00060 ~DateTime(); 00062 DateTime& operator=(const DateTime& dt); 00066 DateTime& operator=(const KDateTime& dt); 00067 00069 bool isNull() const; 00071 bool isValid() const; 00073 bool isDateOnly() const; 00077 void setDateOnly(bool d); 00078 00080 QDate date() const; 00082 void setDate(const QDate& d); 00083 00086 QDateTime rawDateTime() const; 00088 KDateTime kDateTime() const; 00092 QTime effectiveTime() const; 00095 void setTime(const QTime& t); 00100 QDateTime effectiveDateTime() const; 00102 void setDateTime(const QDateTime& dt); 00103 00108 KDateTime effectiveKDateTime() const; 00112 KDateTime calendarKDateTime() const; 00113 00115 KTimeZone timeZone() const; 00117 KDateTime::Spec timeSpec() const; 00119 void setTimeSpec(const KDateTime::Spec &spec); 00122 KDateTime::SpecType timeType() const; 00124 bool isLocalZone() const; 00126 bool isClockTime() const; 00128 bool isUtc() const; 00130 bool isOffsetFromUtc() const; 00132 int utcOffset() const; 00133 00135 bool isSecondOccurrence() const; 00137 void setSecondOccurrence(bool second); 00138 00140 DateTime toUtc() const; 00143 DateTime toOffsetFromUtc() const; 00145 DateTime toOffsetFromUtc(int utcOffset) const; 00147 DateTime toLocalZone() const; 00149 DateTime toClockTime() const; 00151 DateTime toZone(const KTimeZone& zone) const; 00153 DateTime toTimeSpec(const KDateTime::Spec &spec) const; 00154 00157 uint toTime_t() const; 00162 void setTime_t(uint secs); 00163 00165 DateTime addSecs(qint64 n) const; 00167 DateTime addMins(qint64 n) const; 00169 DateTime addDays(int n) const; 00171 DateTime addMonths(int n) const; 00173 DateTime addYears(int n) const; 00174 00176 int daysTo(const DateTime& dt) const; 00178 int minsTo(const DateTime& dt) const; 00184 int secsTo(const DateTime& dt) const; 00186 qint64 secsTo_long(const DateTime& dt) const; 00187 00192 QString toString(Qt::DateFormat f = Qt::TextDate) const; 00197 QString toString(const QString& format) const; 00202 QString formatLocale(bool shortFormat = true) const; 00203 00207 static void setStartOfDay(const QTime& sod); 00208 00210 static QTime startOfDay(); 00211 00213 KDateTime::Comparison compare(const DateTime &other) const; 00214 00215 KALARMCAL_EXPORT friend bool operator==(const KAlarmCal::DateTime& dt1, const KAlarmCal::DateTime& dt2); 00216 KALARMCAL_EXPORT friend bool operator==(const KDateTime& dt1, const KAlarmCal::DateTime& dt2); 00217 KALARMCAL_EXPORT friend bool operator<(const KAlarmCal::DateTime& dt1, const KAlarmCal::DateTime& dt2); 00218 friend bool operator<(const KDateTime& dt1, const KAlarmCal::DateTime& dt2); 00219 00220 private: 00221 //@cond PRIVATE 00222 class Private; 00223 Private* const d; 00224 //@endcond 00225 }; 00226 00228 KALARMCAL_EXPORT bool operator==(const DateTime& dt1, const DateTime& dt2); 00229 KALARMCAL_EXPORT bool operator==(const KDateTime& dt1, const DateTime& dt2); 00230 00232 inline bool operator!=(const DateTime& dt1, const DateTime& dt2) { return !operator==(dt1, dt2); } 00233 inline bool operator!=(const KDateTime& dt1, const DateTime& dt2) { return !operator==(dt1, dt2); } 00234 00239 KALARMCAL_EXPORT bool operator<(const DateTime& dt1, const DateTime& dt2); 00240 inline bool operator<(const KDateTime& dt1, const DateTime& dt2) { return operator<(DateTime(dt1), dt2); } 00241 00246 inline bool operator>(const DateTime& dt1, const DateTime& dt2) { return operator<(dt2, dt1); } 00247 inline bool operator>(const KDateTime& dt1, const DateTime& dt2) { return operator<(dt2, DateTime(dt1)); } 00248 00253 inline bool operator>=(const DateTime& dt1, const DateTime& dt2) { return !operator<(dt1, dt2); } 00254 inline bool operator>=(const KDateTime& dt1, const DateTime& dt2) { return !operator<(DateTime(dt1), dt2); } 00255 00260 inline bool operator<=(const DateTime& dt1, const DateTime& dt2) { return !operator<(dt2, dt1); } 00261 inline bool operator<=(const KDateTime& dt1, const DateTime& dt2) { return !operator<(dt2, DateTime(dt1)); } 00262 00263 } // namespace KAlarmCal 00264 00265 #endif // KALARM_DATETIME_H 00266 00267 // vim: et sw=4:
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:50:08 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:50:08 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.