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 KDATETIMEPARSER_H |
21 | #define KDATETIMEPARSER_H |
22 | |
23 | #include "klocale.h" |
24 | #include "kglobal.h" |
25 | |
26 | class QChar; |
27 | class QString; |
28 | class QDate; |
29 | class QTime; |
30 | |
31 | class KDateTime; |
32 | class KCalendarSystem; |
33 | |
34 | struct DateTimeComponents { |
35 | int day; |
36 | int month; |
37 | int year; |
38 | bool parsedYear; |
39 | QString eraName; |
40 | int yearInEra; |
41 | int dayInYear; |
42 | int isoWeekNumber; |
43 | int dayOfIsoWeek; |
44 | int inputPosition; |
45 | int formatPosition; |
46 | bool error; |
47 | }; |
48 | |
49 | class KDateTimeParser |
50 | { |
51 | public: |
52 | explicit KDateTimeParser(); |
53 | |
54 | virtual ~KDateTimeParser(); |
55 | |
56 | virtual QDate parseDate(const QString &dateString, |
57 | const QString &format, |
58 | const KCalendarSystem *calendar = KGlobal::locale()->calendar(), |
59 | const KLocale *locale = KGlobal::locale(), |
60 | KLocale::DigitSet digitSet = KLocale::ArabicDigits, |
61 | KLocale::DateTimeFormatStandard standard = KLocale::KdeFormat) const; |
62 | |
63 | private: |
64 | virtual DateTimeComponents parseDatePosix(const QString &dateString, |
65 | const QString &format, |
66 | const KCalendarSystem *calendar, |
67 | const KLocale *locale, |
68 | KLocale::DigitSet digitSet, |
69 | KLocale::DateTimeFormatStandard standard) const; |
70 | |
71 | virtual DateTimeComponents parseDateUnicode(const QString &inputString, |
72 | const QString &format, |
73 | const KCalendarSystem *calendar, |
74 | const KLocale *locale, |
75 | KLocale::DigitSet digitSet) const; |
76 | |
77 | virtual int integerFromString(const QString &string, int maxLength, int &readLength) const; |
78 | }; |
79 | |
80 | #endif // KDATETIMEPARSER_H |
81 | |