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

KAlarm Library

  • sources
  • kde-4.12
  • kdepimlibs
  • 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 
29 namespace KAlarmCal
30 {
31 
42 class 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 
228 KALARMCAL_EXPORT bool operator==(const DateTime& dt1, const DateTime& dt2);
229 KALARMCAL_EXPORT bool operator==(const KDateTime& dt1, const DateTime& dt2);
230 
232 inline bool operator!=(const DateTime& dt1, const DateTime& dt2) { return !operator==(dt1, dt2); }
233 inline bool operator!=(const KDateTime& dt1, const DateTime& dt2) { return !operator==(dt1, dt2); }
234 
239 KALARMCAL_EXPORT bool operator<(const DateTime& dt1, const DateTime& dt2);
240 inline bool operator<(const KDateTime& dt1, const DateTime& dt2) { return operator<(DateTime(dt1), dt2); }
241 
246 inline bool operator>(const DateTime& dt1, const DateTime& dt2) { return operator<(dt2, dt1); }
247 inline bool operator>(const KDateTime& dt1, const DateTime& dt2) { return operator<(dt2, DateTime(dt1)); }
248 
253 inline bool operator>=(const DateTime& dt1, const DateTime& dt2) { return !operator<(dt1, dt2); }
254 inline bool operator>=(const KDateTime& dt1, const DateTime& dt2) { return !operator<(DateTime(dt1), dt2); }
255 
260 inline bool operator<=(const DateTime& dt1, const DateTime& dt2) { return !operator<(dt2, dt1); }
261 inline 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:42
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:14 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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