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

Nepomuk

  • nepomuk
  • utils
daterange.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2009-2010 Sebastian Trueg <trueg@kde.org>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License or (at your option) version 3 or any later version
8 accepted by the membership of KDE e.V. (or its successor approved
9 by the membership of KDE e.V.), which shall act as a proxy
10 defined in Section 14 of version 3 of the license.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20*/
21
22#ifndef _DATE_RANGE_H_
23#define _DATE_RANGE_H_
24
25#include <QtCore/QDate>
26#include <QtCore/QSharedDataPointer>
27
28class QDebug;
29
41class DateRange
42{
43public:
47 DateRange( const QDate& s = QDate(),
48 const QDate& e = QDate() );
49
53 DateRange( const DateRange& other );
54
58 ~DateRange();
59
63 DateRange& operator=( const DateRange& other );
64
68 QDate start() const;
69
73 QDate end() const;
74
79 bool isValid() const;
80
84 void setStart( const QDate& date );
85
89 void setEnd( const QDate& date );
90
95 static DateRange today();
96
102 enum DateRangeFlag {
106 NoDateRangeFlags = 0x0,
107
113 ExcludeFutureDays = 0x1
114 };
115 Q_DECLARE_FLAGS( DateRangeFlags, DateRangeFlag )
116
117
121 static DateRange thisWeek( DateRangeFlags flags = NoDateRangeFlags );
122
129 static DateRange weekOf( const QDate& date, DateRangeFlags flags = NoDateRangeFlags );
130
136 static DateRange thisMonth( DateRangeFlags flags = NoDateRangeFlags );
137
145 static DateRange monthOf( const QDate& date, DateRangeFlags flags = NoDateRangeFlags );
146
151 static DateRange thisYear( DateRangeFlags flags = NoDateRangeFlags );
152
160 static DateRange yearOf( const QDate& date, DateRangeFlags flags = NoDateRangeFlags );
161
165 static DateRange lastNDays( int n );
166
171 static DateRange lastNWeeks( int n );
172
177 static DateRange lastNMonths( int n );
178
179private:
180 class Private;
181 QSharedDataPointer<Private> d;
182};
183
189bool operator==( const DateRange& r1, const DateRange& r2 );
190
196bool operator!=( const DateRange& r1, const DateRange& r2 );
197
203uint qHash( const DateRange& range );
204
210QDebug operator<<( QDebug dbg, const DateRange& range );
211
212Q_DECLARE_OPERATORS_FOR_FLAGS( DateRange::DateRangeFlags )
213
214#endif
DateRange
A simple data structure storing a start and an end date.
Definition: daterange.h:42
DateRange::qHash
uint qHash(const DateRange &range)
Allows using DateRange in hashed structures such as QHash or QMap.
DateRange::~DateRange
~DateRange()
Destructor.
DateRange::end
QDate end() const
End date of the range.
DateRange::lastNMonths
static DateRange lastNMonths(int n)
DateRange::lastNDays
static DateRange lastNDays(int n)
DateRange::today
static DateRange today()
DateRange::DateRange
DateRange(const DateRange &other)
Copy constructor.
DateRange::monthOf
static DateRange monthOf(const QDate &date, DateRangeFlags flags=NoDateRangeFlags)
DateRange::weekOf
static DateRange weekOf(const QDate &date, DateRangeFlags flags=NoDateRangeFlags)
Takes KLocale::weekStartDay() into account.
DateRange::setStart
void setStart(const QDate &date)
Set the start to date.
DateRange::operator=
DateRange & operator=(const DateRange &other)
Make this range a copy of other.
DateRange::thisMonth
static DateRange thisMonth(DateRangeFlags flags=NoDateRangeFlags)
DateRange::setEnd
void setEnd(const QDate &date)
Set the end to date.
DateRange::isValid
bool isValid() const
Checks if both start and end are valid dates and if end is after start.
DateRange::lastNWeeks
static DateRange lastNWeeks(int n)
DateRange::yearOf
static DateRange yearOf(const QDate &date, DateRangeFlags flags=NoDateRangeFlags)
DateRange::DateRangeFlag
DateRangeFlag
The flags allow to change the result returned by several of the static factory methods provided by Da...
Definition: daterange.h:102
DateRange::ExcludeFutureDays
@ ExcludeFutureDays
Exclude days that are in the future.
Definition: daterange.h:113
DateRange::NoDateRangeFlags
@ NoDateRangeFlags
No flags.
Definition: daterange.h:106
DateRange::DateRange
DateRange(const QDate &s=QDate(), const QDate &e=QDate())
Create a new range.
DateRange::thisWeek
static DateRange thisWeek(DateRangeFlags flags=NoDateRangeFlags)
Takes KLocale::weekStartDay() into account.
DateRange::start
QDate start() const
Start date of the range.
DateRange::thisYear
static DateRange thisYear(DateRangeFlags flags=NoDateRangeFlags)
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.

Nepomuk

Skip menu "Nepomuk"
  • 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