File indexing completed on 2024-04-14 14:20:00

0001 /*
0002     Copyright 2010 John Layt <john@layt.net>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Library General Public
0006     License as published by the Free Software Foundation; either
0007     version 2 of the License, or (at your option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012     Library General Public License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to
0016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017     Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KDATETIMEPARSER_H
0021 #define KDATETIMEPARSER_H
0022 
0023 #include "klocale.h"
0024 
0025 class QChar;
0026 class QString;
0027 class QDate;
0028 class QTime;
0029 
0030 class KDateTime;
0031 class KCalendarSystem;
0032 
0033 struct DateTimeComponents {
0034     int day;
0035     int month;
0036     int year;
0037     bool parsedYear;
0038     QString eraName;
0039     int yearInEra;
0040     int dayInYear;
0041     int isoWeekNumber;
0042     int dayOfIsoWeek;
0043     int inputPosition;
0044     int formatPosition;
0045     bool error;
0046 };
0047 
0048 class KDateTimeParser
0049 {
0050 public:
0051     KDELIBS4SUPPORT_DEPRECATED explicit KDateTimeParser();
0052 
0053     virtual ~KDateTimeParser();
0054 
0055     virtual QDate parseDate(const QString &dateString,
0056                             const QString &format,
0057                             const KCalendarSystem *calendar  = KLocale::global()->calendar(),
0058                             const KLocale *locale = KLocale::global(),
0059                             KLocale::DigitSet digitSet = KLocale::ArabicDigits,
0060                             KLocale::DateTimeFormatStandard standard = KLocale::KdeFormat) const;
0061 
0062 private:
0063     virtual DateTimeComponents parseDatePosix(const QString &dateString,
0064             const QString &format,
0065             const KCalendarSystem *calendar,
0066             const KLocale *locale,
0067             KLocale::DigitSet digitSet,
0068             KLocale::DateTimeFormatStandard standard) const;
0069 
0070     virtual DateTimeComponents parseDateUnicode(const QString &inputString,
0071             const QString &format,
0072             const KCalendarSystem *calendar,
0073             const KLocale *locale,
0074             KLocale::DigitSet digitSet) const;
0075 
0076     virtual int integerFromString(const QString &string, int maxLength, int &readLength) const;
0077 };
0078 
0079 #endif // KDATETIMEPARSER_H