• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

KAlarm Library

  • kalarmcal
datetime.h
1/*
2 * datetime.h - date/time with start-of-day time for date-only values
3 * This file is part of kalarmcal library, which provides access to KAlarm
4 * calendar data.
5 * Copyright © 2003,2005-2007,2009,2011 by David Jarvie <djarvie@kde.org>
6 *
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Library General Public License as published
9 * by the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
21 */
22#ifndef KALARM_DATETIME_H
23#define KALARM_DATETIME_H
24
25#include "kalarmcal_export.h"
26
27#include <kdatetime.h>
28
29namespace KAlarmCal
30{
31
42class KALARMCAL_EXPORT DateTime
43{
44 public:
48 DateTime();
50 DateTime(const QDate& d, const KDateTime::Spec& spec);
52 DateTime(const QDate& d, const QTime& t, const KDateTime::Spec& spec);
54 DateTime(const QDateTime& dt, const KDateTime::Spec& spec);
56 DateTime(const KDateTime& dt);
58 DateTime(const DateTime& dt);
59
60 ~DateTime();
62 DateTime& operator=(const DateTime& dt);
66 DateTime& operator=(const KDateTime& dt);
67
69 bool isNull() const;
71 bool isValid() const;
73 bool isDateOnly() const;
77 void setDateOnly(bool d);
78
80 QDate date() const;
82 void setDate(const QDate& d);
83
86 QDateTime rawDateTime() const;
88 KDateTime kDateTime() const;
92 QTime effectiveTime() const;
95 void setTime(const QTime& t);
100 QDateTime effectiveDateTime() const;
102 void setDateTime(const QDateTime& dt);
103
108 KDateTime effectiveKDateTime() const;
112 KDateTime calendarKDateTime() const;
113
115 KTimeZone timeZone() const;
117 KDateTime::Spec timeSpec() const;
119 void setTimeSpec(const KDateTime::Spec &spec);
122 KDateTime::SpecType timeType() const;
124 bool isLocalZone() const;
126 bool isClockTime() const;
128 bool isUtc() const;
130 bool isOffsetFromUtc() const;
132 int utcOffset() const;
133
135 bool isSecondOccurrence() const;
137 void setSecondOccurrence(bool second);
138
140 DateTime toUtc() const;
143 DateTime toOffsetFromUtc() const;
145 DateTime toOffsetFromUtc(int utcOffset) const;
147 DateTime toLocalZone() const;
149 DateTime toClockTime() const;
151 DateTime toZone(const KTimeZone& zone) const;
153 DateTime toTimeSpec(const KDateTime::Spec &spec) const;
154
157 uint toTime_t() const;
162 void setTime_t(uint secs);
163
165 DateTime addSecs(qint64 n) const;
167 DateTime addMins(qint64 n) const;
169 DateTime addDays(int n) const;
171 DateTime addMonths(int n) const;
173 DateTime addYears(int n) const;
174
176 int daysTo(const DateTime& dt) const;
178 int minsTo(const DateTime& dt) const;
184 int secsTo(const DateTime& dt) const;
186 qint64 secsTo_long(const DateTime& dt) const;
187
192 QString toString(Qt::DateFormat f = Qt::TextDate) const;
197 QString toString(const QString& format) const;
202 QString formatLocale(bool shortFormat = true) const;
203
207 static void setStartOfDay(const QTime& sod);
208
210 static QTime startOfDay();
211
213 KDateTime::Comparison compare(const DateTime &other) const;
214
215 KALARMCAL_EXPORT friend bool operator==(const KAlarmCal::DateTime& dt1, const KAlarmCal::DateTime& dt2);
216 KALARMCAL_EXPORT friend bool operator==(const KDateTime& dt1, const KAlarmCal::DateTime& dt2);
217 KALARMCAL_EXPORT friend bool operator<(const KAlarmCal::DateTime& dt1, const KAlarmCal::DateTime& dt2);
218 friend bool operator<(const KDateTime& dt1, const KAlarmCal::DateTime& dt2);
219
220 private:
221 //@cond PRIVATE
222 class Private;
223 Private* const d;
224 //@endcond
225};
226
228KALARMCAL_EXPORT bool operator==(const DateTime& dt1, const DateTime& dt2);
229KALARMCAL_EXPORT bool operator==(const KDateTime& dt1, const DateTime& dt2);
230
232inline bool operator!=(const DateTime& dt1, const DateTime& dt2) { return !operator==(dt1, dt2); }
233inline bool operator!=(const KDateTime& dt1, const DateTime& dt2) { return !operator==(dt1, dt2); }
234
239KALARMCAL_EXPORT bool operator<(const DateTime& dt1, const DateTime& dt2);
240inline bool operator<(const KDateTime& dt1, const DateTime& dt2) { return operator<(DateTime(dt1), dt2); }
241
246inline bool operator>(const DateTime& dt1, const DateTime& dt2) { return operator<(dt2, dt1); }
247inline bool operator>(const KDateTime& dt1, const DateTime& dt2) { return operator<(dt2, DateTime(dt1)); }
248
253inline bool operator>=(const DateTime& dt1, const DateTime& dt2) { return !operator<(dt1, dt2); }
254inline bool operator>=(const KDateTime& dt1, const DateTime& dt2) { return !operator<(DateTime(dt1), dt2); }
255
260inline bool operator<=(const DateTime& dt1, const DateTime& dt2) { return !operator<(dt2, dt1); }
261inline bool operator<=(const KDateTime& dt1, const DateTime& dt2) { return !operator<(dt2, DateTime(dt1)); }
262
263} // namespace KAlarmCal
264
265#endif // KALARM_DATETIME_H
266
267// vim: et sw=4:
KAlarmCal::DateTime
As KDateTime, but with a configurable start-of-day time for date-only values.
Definition: datetime.h:43
operator!=
bool operator!=(const location &loc1, const location &loc2)
operator==
bool operator==(const location &loc1, const location &loc2)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KAlarm Library

Skip menu "KAlarm Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal