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 KDATETIMEFORMATTER_H
21#define KDATETIMEFORMATTER_H
22
23#include "klocale.h"
24#include "kglobal.h"
25
26class QChar;
27class QString;
28class QDate;
29class QTime;
30
31class KDateTime;
32class KCalendarSystem;
33
34class KDateTimeFormatter
35{
36public:
37 explicit KDateTimeFormatter();
38
39 virtual ~KDateTimeFormatter();
40
41 virtual QString formatDate(const QDate &fromDate,
42 const QString &toFormat,
43 const KCalendarSystem *calendar = KGlobal::locale()->calendar(),
44 const KLocale *locale = KGlobal::locale(),
45 KLocale::DigitSet digitSet = KGlobal::locale()->dateTimeDigitSet(),
46 KLocale::DateTimeFormatStandard standard = KLocale::KdeFormat) const;
47
48 virtual QString formatTime(const QTime &fromTime,
49 const QString &toFormat,
50 KLocale::TimeFormatOptions timeOptions = 0,
51 const KCalendarSystem *calendar = KGlobal::locale()->calendar(),
52 const KLocale *locale = KGlobal::locale(),
53 KLocale::DigitSet digitSet = KGlobal::locale()->dateTimeDigitSet(),
54 KLocale::DateTimeFormatStandard standard = KLocale::KdeFormat) const;
55
56 virtual QString formatDateTime(const KDateTime &fromDateTime,
57 const QString &toFormat,
58 KLocale::TimeFormatOptions timeOptions = 0,
59 const KCalendarSystem *calendar = KGlobal::locale()->calendar(),
60 const KLocale *locale = KGlobal::locale(),
61 KLocale::DigitSet digitSet = KGlobal::locale()->dateTimeDigitSet(),
62 KLocale::DateTimeFormatStandard standard = KLocale::KdeFormat) const;
63
64private:
65 virtual QString formatDateTimePosix(const KDateTime &fromDateTime,
66 const QString &toFormat,
67 KLocale::TimeFormatOptions timeOptions,
68 const KCalendarSystem *calendar,
69 const KLocale *locale,
70 KLocale::DigitSet digitSet,
71 KLocale::DateTimeFormatStandard standard) const;
72
73 virtual void initEnglish(const KCalendarSystem *calendar, const KLocale *locale) const;
74
75 virtual QString formatDateTimeUnicode(const KDateTime &fromDateTime,
76 const QString &toFormat,
77 KLocale::TimeFormatOptions timeOptions,
78 const KCalendarSystem *calendar,
79 const KLocale *locale,
80 KLocale::DigitSet digitSet) const;
81
82 virtual QString getUnicodeString(const KDateTime &fromDateTime,
83 const QString &toFormat,
84 KLocale::TimeFormatOptions timeOptions,
85 const KCalendarSystem *calendar,
86 const KLocale *locale,
87 KLocale::DigitSet digitSet) const;
88
89 virtual QString stringFromInteger(int number, int padWidth, QChar padChar, QChar signChar,
90 KLocale::DigitSet digitSet, const KLocale *locale) const;
91
92 // Is private class, but if ever made public need to move these into a d->
93 // Some format modifiers force English names to be returned
94 mutable KLocale *m_englishLocale;
95 mutable KCalendarSystem *m_englishCalendar;
96};
97
98#endif // KDATETIMEFORMATTER_H
99