• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • date
klocalizeddate.h
Go to the documentation of this file.
1/*
2 Copyright 2010 John Layt <john@layt.net>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KLOCALIZEDDATE_H
21#define KLOCALIZEDDATE_H
22
23#include <QtCore/QString>
24#include <QtCore/QDate>
25
26#include <kdecore_export.h>
27#include "kcalendarsystem.h"
28#include "klocale.h"
29
30class KLocalizedDatePrivate;
138class KDECORE_EXPORT KLocalizedDate
139{
140public:
141
156 explicit KLocalizedDate(const QDate &date = QDate(), const KCalendarSystem *calendar = 0);
157
174 KLocalizedDate(int year, int month, int day, const KCalendarSystem *calendar = 0);
175
181 KLocalizedDate(const KLocalizedDate &rhs);
182
188 KLocalizedDate &operator=(const KLocalizedDate &rhs);
189
195 KLocalizedDate &operator=(const QDate &rhs);
196
200 ~KLocalizedDate();
201
220 void setCalendarSystem(KLocale::CalendarSystem calendarSystem);
221
229 KLocale::CalendarSystem calendarSystem();
230
245 const KCalendarSystem *calendar() const;
246
253 bool isNull() const;
254
261 bool isValid() const;
262
269 bool setDate(const QDate &date);
270
283 bool setDate(int year, int month, int day);
284
293 bool setDate(int year, int dayOfYear);
294
306 bool setDate(QString eraName, int yearInEra, int month, int day);
307
321 bool setDate(KLocale::WeekNumberSystem weekNumberSystem, int year, int weekOfYear, int dayOfWeek);
322
329 bool setCurrentDate();
330
338 static KLocalizedDate currentDate();
339
347 static KLocalizedDate fromDate(const QDate &date);
348
357 static KLocalizedDate fromJulianDay(int jd);
358
365 int toJulianDay() const;
366
372 QDate date() const;
373
386 void getDate(int *year, int *month, int *day) const;
387
396 int year() const;
397
406 int month() const;
407
416 int day() const;
417
427 QString eraName() const;
428
438 QString eraYear() const;
439
450 int yearInEra() const;
451
462 int dayOfYear() const;
463
476 int dayOfWeek() const;
477
496 int week(int *yearNum = 0) const;
497
519 int week(KLocale::WeekNumberSystem weekNumberSystem, int *yearNum = 0) const;
520
529 int monthsInYear() const;
530
543 int weeksInYear() const;
544
559 int weeksInYear(KLocale::WeekNumberSystem weekNumberSystem) const;
560
572 int daysInYear() const;
573
582 int daysInMonth() const;
583
592 int daysInWeek() const;
593
600 bool isLeapYear() const;
601
613 QString formatDate(KLocale::DateFormat dateFormat = KLocale::LongDate) const;
614
726 QString formatDate(const QString &formatString,
727 KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat) const;
728
751 QString formatDate(KLocale::DateTimeComponent component,
752 KLocale::DateTimeComponentFormat format = KLocale::DefaultComponentFormat,
753 KLocale::WeekNumberSystem weekNumberSystem = KLocale::DefaultWeekNumber) const;
754
773 static KLocalizedDate readDate(const QString &dateString,
774 KLocale::DateTimeParseMode parseMode = KLocale::LiberalParsing,
775 const KCalendarSystem *calendar = 0);
776
795 static KLocalizedDate readDate(const QString &dateString,
796 KLocale::ReadDateFlags formatFlags,
797 KLocale::DateTimeParseMode parseMode = KLocale::LiberalParsing,
798 const KCalendarSystem *calendar = 0);
799
819 static KLocalizedDate readDate(const QString &dateString,
820 const QString &dateFormat,
821 KLocale::DateTimeParseMode parseMode = KLocale::LiberalParsing,
822 KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat,
823 const KCalendarSystem *calendar = 0);
824
834 KLocalizedDate addYears(int years) const;
835
848 bool addYearsTo(int years);
849
859 KLocalizedDate addMonths(int months) const;
860
873 bool addMonthsTo(int months);
874
884 KLocalizedDate addDays(int days) const;
885
898 bool addDaysTo(int days);
899
923 void dateDifference(const KLocalizedDate &toDate,
924 int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const;
925
949 void dateDifference(const QDate &toDate,
950 int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const;
951
965 int yearsDifference(const KLocalizedDate &toDate) const;
966
980 int yearsDifference(const QDate &toDate) const;
981
997 int monthsDifference(const KLocalizedDate &toDate) const;
998
1014 int monthsDifference(const QDate &toDate) const;
1015
1025 int daysDifference(const KLocalizedDate &toDate) const;
1026
1036 int daysDifference(const QDate &toDate) const;
1037
1044 KLocalizedDate firstDayOfYear() const;
1045
1052 KLocalizedDate lastDayOfYear() const;
1053
1060 KLocalizedDate firstDayOfMonth() const;
1061
1068 KLocalizedDate lastDayOfMonth() const;
1069
1075 bool operator==(const KLocalizedDate &other) const;
1076
1082 bool operator==(const QDate &other) const;
1083
1089 bool operator!=(const KLocalizedDate &other) const;
1090
1096 bool operator!=(const QDate &other) const;
1097
1103 bool operator<(const KLocalizedDate &other) const;
1104
1110 bool operator<(const QDate &other) const;
1111
1117 bool operator<=(const KLocalizedDate &other) const;
1118
1124 bool operator<=(const QDate &other) const;
1125
1131 bool operator>(const KLocalizedDate &other) const;
1132
1138 bool operator>(const QDate &other) const;
1139
1145 bool operator>=(const KLocalizedDate &other) const;
1146
1152 bool operator>=(const QDate &other) const;
1153
1154private:
1155
1156 friend QDataStream KDECORE_EXPORT &operator<<(QDataStream &out, const KLocalizedDate &date);
1157 friend QDataStream KDECORE_EXPORT &operator>>(QDataStream &in, KLocalizedDate &date);
1158 friend QDebug KDECORE_EXPORT operator<<(QDebug, const KLocalizedDate &);
1159
1160 QSharedDataPointer<KLocalizedDatePrivate> d;
1161};
1162
1163Q_DECLARE_METATYPE(KLocalizedDate)
1164
1165
1171QDataStream KDECORE_EXPORT &operator<<(QDataStream &out, const KLocalizedDate &date);
1172
1179QDataStream KDECORE_EXPORT &operator>>(QDataStream &in, KLocalizedDate &date);
1180
1187QDebug KDECORE_EXPORT operator<<(QDebug debug, const KLocalizedDate &date);
1188
1189#endif // KLOCALIZEDDATE_H
KCalendarSystem
KCalendarSystem abstract base class, provides support for local Calendar Systems in KDE.
Definition: kcalendarsystem.h:41
KLocale::WeekNumberSystem
WeekNumberSystem
Definition: klocale.h:815
KLocale::DefaultWeekNumber
@ DefaultWeekNumber
The system locale default.
Definition: klocale.h:816
KLocale::DateTimeFormatStandard
DateTimeFormatStandard
Definition: klocale.h:829
KLocale::KdeFormat
@ KdeFormat
KDE Standard.
Definition: klocale.h:830
KLocale::ReadDateFlags
ReadDateFlags
Flags for readDate()
Definition: klocale.h:1249
KLocale::DateTimeComponent
DateTimeComponent
Definition: klocale.h:865
KLocale::DateFormat
DateFormat
Format for date string.
Definition: klocale.h:922
KLocale::LongDate
@ LongDate
Locale Long date format, e.g.
Definition: klocale.h:924
KLocale::CalendarSystem
CalendarSystem
Definition: klocale.h:780
KLocale::DateTimeParseMode
DateTimeParseMode
Definition: klocale.h:841
KLocale::LiberalParsing
@ LiberalParsing
Parse Date/Time liberally.
Definition: klocale.h:842
KLocale::DateTimeComponentFormat
DateTimeComponentFormat
Definition: klocale.h:908
KLocale::DefaultComponentFormat
@ DefaultComponentFormat
The system locale default for the componant.
Definition: klocale.h:909
KLocalizedDate
A class representing a date localized using the local calendar system, language and formats.
Definition: klocalizeddate.h:139
QString
kcalendarsystem.h
operator<<
QDebug operator<<(QDebug dbg, const KEntryKey &key)
Definition: kconfigdata.cpp:25
operator==
bool operator==(const KEntry &k1, const KEntry &k2)
Definition: kconfigdata.h:72
operator<
bool operator<(const KEntryKey &k1, const KEntryKey &k2)
Compares two KEntryKeys (needed for QMap).
Definition: kconfigdata.h:124
operator!=
bool operator!=(const KEntry &k1, const KEntry &k2)
Definition: kconfigdata.h:79
operator>>
QDataStream & operator>>(QDataStream &s, KDateTime::Spec &spec)
Read a KDateTime::Spec object into spec from in, in binary format.
Definition: kdatetime.cpp:274
kdecore_export.h
klocale.h
operator>>
QDataStream & operator>>(QDataStream &in, KLocalizedDate &date)
Data stream input operator.
Definition: klocalizeddate.cpp:595
operator<<
QDataStream & operator<<(QDataStream &out, const KLocalizedDate &date)
Data stream output operator.
Definition: klocalizeddate.cpp:590
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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