summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/timestring.h32
1 files changed, 11 insertions, 21 deletions
diff --git a/library/timestring.h b/library/timestring.h
index b8d1aea..9a2889b 100644
--- a/library/timestring.h
+++ b/library/timestring.h
@@ -1,40 +1,30 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2006 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2006 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This program is free software; you can redistribute it and/or modify it 6** This program is free software; you can redistribute it and/or modify it
7** under the terms of the GNU General Public License as published by the 7** under the terms of the GNU General Public License as published by the
8** Free Software Foundation; either version 2 of the License, or (at your 8** Free Software Foundation; either version 2 of the License, or (at your
9** option) any later version. 9** option) any later version.
10** 10**
11** A copy of the GNU GPL license version 2 is included in this package as 11** A copy of the GNU GPL license version 2 is included in this package as
12** LICENSE.GPL. 12** LICENSE.GPL.
13** 13**
14** This program is distributed in the hope that it will be useful, but 14** This program is distributed in the hope that it will be useful, but
15** WITHOUT ANY WARRANTY; without even the implied warranty of 15** WITHOUT ANY WARRANTY; without even the implied warranty of
16** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17** See the GNU General Public License for more details. 17** See the GNU General Public License for more details.
18** 18**
19** In addition, as a special exception Trolltech gives permission to link
20** the code of this program with Qtopia applications copyrighted, developed
21** and distributed by Trolltech under the terms of the Qtopia Personal Use
22** License Agreement. You must comply with the GNU General Public License
23** in all respects for all of the code used other than the applications
24** licensed under the Qtopia Personal Use License Agreement. If you modify
25** this file, you may extend this exception to your version of the file,
26** but you are not obligated to do so. If you do not wish to do so, delete
27** this exception statement from your version.
28**
29** See http://www.trolltech.com/gpl/ for GPL licensing information. 19** See http://www.trolltech.com/gpl/ for GPL licensing information.
30** 20**
31** Contact info@trolltech.com if any conditions of this licensing are 21** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you. 22** not clear to you.
33** 23**
34**********************************************************************/ 24**********************************************************************/
35 25
36#ifndef _TIMESTRING_H_ 26#ifndef _TIMESTRING_H_
37#define _TIMESTRING_H_ 27#define _TIMESTRING_H_
38#include <qdatetime.h> 28#include <qdatetime.h>
39#include <qstring.h> 29#include <qstring.h>
40#include <qarray.h> 30#include <qarray.h>
@@ -42,25 +32,25 @@
42#if (QT_VERSION-0 >= 0x030000) 32#if (QT_VERSION-0 >= 0x030000)
43#define DateFormat QPEDateFormat 33#define DateFormat QPEDateFormat
44#endif 34#endif
45 35
46#include <qtopia/qpeglobal.h> 36#include <qtopia/qpeglobal.h>
47 37
48class QObject; 38class QObject;
49 39
50// return a string with the time based on whether or not you want 40// return a string with the time based on whether or not you want
51// you want it in 12 hour form. if ampm is true, then return 41// you want it in 12 hour form. if ampm is true, then return
52// it in 12 hour (am/pm) form otherwise return it in 24 hour form 42// it in 12 hour (am/pm) form otherwise return it in 24 hour form
53// in theory Qt 3,0 handles this better (hopefully obsoleteing this) 43// in theory Qt 3,0 handles this better (hopefully obsoleteing this)
54class DateFormat 44class DateFormat
55{ 45{
56public: 46public:
57 // date format type 1,2,4 = day,month,year 47 // date format type 1,2,4 = day,month,year
58 enum Order { 48 enum Order {
59 DayMonthYear = 0421, // right-to-left 49 DayMonthYear = 0421, // right-to-left
60 MonthDayYear = 0412, 50 MonthDayYear = 0412,
61 YearMonthDay = 0124 51 YearMonthDay = 0124
62 }; 52 };
63 53
64 DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so), 54 DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so),
65 _longOrder(so), _shortSeparator(s) { } 55 _longOrder(so), _shortSeparator(s) { }
66 DateFormat(QChar s, Order so, Order lo) : _shortOrder(so), 56 DateFormat(QChar s, Order so, Order lo) : _shortOrder(so),
@@ -110,30 +100,30 @@ private:
110 QChar _shortSeparator; 100 QChar _shortSeparator;
111}; 101};
112 102
113#ifndef QT_NO_DATASTREAM 103#ifndef QT_NO_DATASTREAM
114QDataStream &operator<<(QDataStream &s, const DateFormat&df); 104QDataStream &operator<<(QDataStream &s, const DateFormat&df);
115QDataStream &operator>>(QDataStream &s, DateFormat&df); 105QDataStream &operator>>(QDataStream &s, DateFormat&df);
116#endif 106#endif
117 107
118class TimeString 108class TimeString
119{ 109{
120public: 110public:
121 111
122 //enum DateFormat { MonthDayYear, DayMonthYear, ISO8601, 112 //enum DateFormat { MonthDayYear, DayMonthYear, ISO8601,
123 //YearMonthDay = ISO8601 }; 113 //YearMonthDay = ISO8601 };
124 114
125 115
126//private: 116//private:
127 static QString shortDate( const QDate &d ) 117 static QString shortDate( const QDate &d )
128 { return shortDate( d, currentDateFormat() ); } 118 { return shortDate( d, currentDateFormat() ); }
129 static QString dateString( const QDate &d ) 119 static QString dateString( const QDate &d )
130 { return dateString( d, currentDateFormat() ); } 120 { return dateString( d, currentDateFormat() ); }
131 static QString longDateString( const QDate &d ) 121 static QString longDateString( const QDate &d )
132 { return longDateString( d, currentDateFormat() ); } 122 { return longDateString( d, currentDateFormat() ); }
133 static QString dateString( const QDateTime &dt, bool ampm, bool seconds ) 123 static QString dateString( const QDateTime &dt, bool ampm, bool seconds )
134 { return dateString( dt, ampm, seconds, currentDateFormat() ); } 124 { return dateString( dt, ampm, seconds, currentDateFormat() ); }
135 125
136public: 126public:
137 enum Length { Short, Medium, Long }; 127 enum Length { Short, Medium, Long };
138 static QString localH( int hour ); 128 static QString localH( int hour );
139 static QString localHM( const QTime & ); 129 static QString localHM( const QTime & );
@@ -147,36 +137,36 @@ public:
147 static QString localDayOfWeek( const QDate&, Length=Medium ); 137 static QString localDayOfWeek( const QDate&, Length=Medium );
148 static QString localDayOfWeek( int day1to7, Length=Medium ); 138 static QString localDayOfWeek( int day1to7, Length=Medium );
149 139
150 static QString hourString( int hour, bool ampm ); 140 static QString hourString( int hour, bool ampm );
151 static bool currentAMPM(); 141 static bool currentAMPM();
152 static DateFormat currentDateFormat(); 142 static DateFormat currentDateFormat();
153 static QArray<DateFormat> formatOptions(); // qtopia 1.6.0 143 static QArray<DateFormat> formatOptions(); // qtopia 1.6.0
154 144
155 static void connectChange(QObject*,const char* member); 145 static void connectChange(QObject*,const char* member);
156 static void disconnectChange(QObject*,const char* member); 146 static void disconnectChange(QObject*,const char* member);
157 147
158 // Not recommended to call these (they don't honor system ampm) 148 // Not recommended to call these (they don't honor system ampm)
159 static QString dateString( const QDateTime &t, bool ampm ); 149 static QString dateString( const QDateTime &t, bool ampm = false);
160 static QString timeString( const QTime &t, bool ampm, bool seconds ); 150 static QString timeString( const QTime &t, bool ampm, bool seconds );
161 static QString timeString( const QTime &t, bool ampm ); 151 static QString timeString( const QTime &t, bool ampm = false);
162 static QString shortTime( bool ampm, bool seconds ); 152 static QString shortTime( bool ampm, bool seconds );
163 static QString shortTime( bool ampm ); 153 static QString shortTime( bool ampm = false);
164 154
165 static QString numberDateString( const QDate &d, DateFormat ); 155 static QString numberDateString( const QDate &d, DateFormat );
166 static QString numberDateString( const QDate &d ) 156 static QString numberDateString( const QDate &d )
167 { return numberDateString( d, currentDateFormat() ); } 157 { return numberDateString( d, currentDateFormat() ); }
168 static QString longNumberDateString( const QDate &d, DateFormat ); 158 static QString longNumberDateString( const QDate &d, DateFormat );
169 static QString longNumberDateString( const QDate &d ) 159 static QString longNumberDateString( const QDate &d )
170 { return longNumberDateString( d, currentDateFormat() ); } 160 { return longNumberDateString( d, currentDateFormat() ); }
171 161
172 static QString shortDate( const QDate &, DateFormat ); 162 static QString shortDate( const QDate &, DateFormat );
173 static QString dateString( const QDate &, DateFormat ); 163 static QString dateString( const QDate &, DateFormat );
174 static QString longDateString( const QDate &, DateFormat ); 164 static QString longDateString( const QDate &, DateFormat );
175 165
176private: 166private:
177 static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat ); 167 static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat );
178 168
179 169
180}; 170};
181 171
182#endif 172#endif