1 /* SPDX-FileCopyrightText: 2003-2010 Jesper K. Pedersen <blackie@kde.org> 2 3 SPDX-License-Identifier: GPL-2.0-or-later 4 */ 5 6 #ifndef IMAGEDATE_H 7 #define IMAGEDATE_H 8 #include <Utilities/FastDateTime.h> 9 #include <qstring.h> 10 #include <qstringlist.h> 11 12 namespace DB 13 { 14 15 class ImageDate 16 { 17 public: 18 ImageDate(); 19 ImageDate(const QDate &start, const QDate &end); 20 ImageDate(const Utilities::FastDateTime &start, const Utilities::FastDateTime &end); 21 ImageDate(int yearFrom, int monthFrom, int dayFrom, int yearTo, int monthTo, int dayTo, int hourFrom, int minuteFrom, int secondFrom); 22 explicit ImageDate(const QDate &); 23 explicit ImageDate(const Utilities::FastDateTime &); 24 ImageDate(const QDate &start, QDate end, const QTime &time); 25 start()26 const Utilities::FastDateTime &start() const { return m_start; } end()27 const Utilities::FastDateTime &end() const { return m_end; } 28 static QDate parseDate(const QString &date, bool startDate); 29 30 bool operator<(const ImageDate &other) const; 31 bool operator<=(const ImageDate &other) const; 32 bool operator==(const ImageDate &other) const; 33 bool operator!=(const ImageDate &other) const; 34 isValid()35 bool isValid() const { return !isNull(); } 36 bool isNull() const; 37 bool isFuzzy() const; 38 QString toString(bool withTime = true) const; 39 bool hasValidTime() const; 40 41 enum MatchType { DontMatch, 42 ExactMatch, 43 RangeMatch }; 44 MatchType isIncludedIn(const ImageDate &searchRange) const; 45 bool includes(const Utilities::FastDateTime &date) const; 46 47 void extendTo(const ImageDate &other); 48 49 protected: 50 static QStringList monthNames(); 51 static QString formatRegexp(); 52 53 private: 54 Utilities::FastDateTime m_start, m_end; 55 }; 56 } 57 58 #endif /* IMAGEDATE_H */ 59 60 // vi:expandtab:tabstop=4 shiftwidth=4: 61