summaryrefslogtreecommitdiff
path: root/library/timestring.h
authorllornkcor <llornkcor>2006-07-09 18:56:40 (UTC)
committer llornkcor <llornkcor>2006-07-09 18:56:40 (UTC)
commit36dece4760b1ac1799929221b49eb3bee98c2367 (patch) (unidiff)
treea45f66d2d90bd9fbbff8e8903cd1cb9323c39f6e /library/timestring.h
parent604065c6e662cb3894acf03abadafacc3ab52913 (diff)
downloadopie-36dece4760b1ac1799929221b49eb3bee98c2367.zip
opie-36dece4760b1ac1799929221b49eb3bee98c2367.tar.gz
opie-36dece4760b1ac1799929221b49eb3bee98c2367.tar.bz2
initial commit to add video4linux camera app from qtopia 2, needs more work
Diffstat (limited to 'library/timestring.h') (more/less context) (ignore whitespace changes)
-rw-r--r--library/timestring.h94
1 files changed, 63 insertions, 31 deletions
diff --git a/library/timestring.h b/library/timestring.h
index 875c8bf..b8d1aea 100644
--- a/library/timestring.h
+++ b/library/timestring.h
@@ -1,16 +1,31 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 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**
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
8** Free Software Foundation; either version 2 of the License, or (at your
9** option) any later version.
10**
11** A copy of the GNU GPL license version 2 is included in this package as
12** LICENSE.GPL.
5** 13**
6** This file may be distributed and/or modified under the terms of the 14** This program is distributed in the hope that it will be useful, but
7** GNU General Public License version 2 as published by the Free Software 15** WITHOUT ANY WARRANTY; without even the implied warranty of
8** Foundation and appearing in the file LICENSE.GPL included in the 16** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9** packaging of this file. 17** See the GNU General Public License for more details.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 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**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 30**
16** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
@@ -22,23 +37,28 @@
22#define _TIMESTRING_H_ 37#define _TIMESTRING_H_
23#include <qdatetime.h> 38#include <qdatetime.h>
24#include <qstring.h> 39#include <qstring.h>
40#include <qarray.h>
25 41
26#if (QT_VERSION-0 >= 0x030000) 42#if (QT_VERSION-0 >= 0x030000)
27#define DateFormat QPEDateFormat 43#define DateFormat QPEDateFormat
28#endif 44#endif
29 45
46#include <qtopia/qpeglobal.h>
47
48class QObject;
49
30// return a string with the time based on whether or not you want 50// return a string with the time based on whether or not you want
31// you want it in 12 hour form. if ampm is true, then return 51// you want it in 12 hour form. if ampm is true, then return
32// it in 12 hour (am/pm) form otherwise return it in 24 hour form 52// it in 12 hour (am/pm) form otherwise return it in 24 hour form
33// in theory Qt 3,0 handles this better (hopefully obsoleteing this) 53// in theory Qt 3,0 handles this better (hopefully obsoleteing this)
34class DateFormat 54class DateFormat
35{ 55{
36public: 56public:
37 // date format type 001,010,100 = day month year 57 // date format type 1,2,4 = day,month,year
38 enum Order { 58 enum Order {
39 DayMonthYear = 0x0111, // 0x001 + 0x010(0x2 << 3) + 0x100(0x4 << 3) 59 DayMonthYear = 0421, // right-to-left
40 MonthDayYear = 0x010A, 60 MonthDayYear = 0412,
41 YearMonthDay = 0x0054 61 YearMonthDay = 0124
42 }; 62 };
43 63
44 DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so), 64 DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so),
@@ -99,34 +119,48 @@ class TimeString
99{ 119{
100public: 120public:
101 121
102 //enum DateFormat { MonthDayYear, DayMonthYear, ISO8601, 122 //enum DateFormat { MonthDayYear, DayMonthYear, ISO8601,
103 //YearMonthDay = ISO8601 }; 123 //YearMonthDay = ISO8601 };
104 124
105/** 125
106 * @name Convience functions which use currentDateFormat 126//private:
107 */ 127 static QString shortDate( const QDate &d )
108//@{
109 static QString shortDate( const QDate &d )
110 { return shortDate( d, currentDateFormat() ); } 128 { return shortDate( d, currentDateFormat() ); }
111 static QString dateString( const QDate &d ) 129 static QString dateString( const QDate &d )
112 { return dateString( d, currentDateFormat() ); } 130 { return dateString( d, currentDateFormat() ); }
113 static QString longDateString( const QDate &d ) 131 static QString longDateString( const QDate &d )
114 { return longDateString( d, currentDateFormat() ); } 132 { return longDateString( d, currentDateFormat() ); }
115//@}
116 static QString dateString( const QDateTime &dt, bool ampm, bool seconds ) 133 static QString dateString( const QDateTime &dt, bool ampm, bool seconds )
117 { return dateString( dt, ampm, seconds, currentDateFormat() ); } 134 { return dateString( dt, ampm, seconds, currentDateFormat() ); }
118 135
136public:
137 enum Length { Short, Medium, Long };
138 static QString localH( int hour );
139 static QString localHM( const QTime & );
140 static QString localHM( const QTime &, Length ); // qtopia 2.1.0
141 static QString localHMS( const QTime & );
142 static QString localHMDayOfWeek( const QDateTime &t );
143 static QString localHMSDayOfWeek( const QDateTime &t );
144 static QString localMD( const QDate &, Length=Medium );
145 static QString localYMD( const QDate &, Length=Medium );
146 static QString localYMDHMS( const QDateTime &, Length=Medium );
147 static QString localDayOfWeek( const QDate&, Length=Medium );
148 static QString localDayOfWeek( int day1to7, Length=Medium );
149
150 static QString hourString( int hour, bool ampm );
151 static bool currentAMPM();
152 static DateFormat currentDateFormat();
153 static QArray<DateFormat> formatOptions(); // qtopia 1.6.0
154
155 static void connectChange(QObject*,const char* member);
156 static void disconnectChange(QObject*,const char* member);
119 157
120 /** @name Do not use as they don't honor system settings for AMPM 158 // Not recommended to call these (they don't honor system ampm)
121 * 159 static QString dateString( const QDateTime &t, bool ampm );
122 */
123 //@{
124 static QString dateString( const QDateTime &t, bool ampm = false );
125 static QString timeString( const QTime &t, bool ampm, bool seconds ); 160 static QString timeString( const QTime &t, bool ampm, bool seconds );
126 static QString timeString( const QTime &t, bool ampm = false ); 161 static QString timeString( const QTime &t, bool ampm );
127 static QString shortTime( bool ampm, bool seconds ); 162 static QString shortTime( bool ampm, bool seconds );
128 static QString shortTime( bool ampm = false ); 163 static QString shortTime( bool ampm );
129 //@}
130 164
131 static QString numberDateString( const QDate &d, DateFormat ); 165 static QString numberDateString( const QDate &d, DateFormat );
132 static QString numberDateString( const QDate &d ) 166 static QString numberDateString( const QDate &d )
@@ -139,11 +173,9 @@ public:
139 static QString dateString( const QDate &, DateFormat ); 173 static QString dateString( const QDate &, DateFormat );
140 static QString longDateString( const QDate &, DateFormat ); 174 static QString longDateString( const QDate &, DateFormat );
141 175
142 static DateFormat currentDateFormat();
143
144private: 176private:
145 static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat ); 177 static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat );
146 178
147 179
148}; 180};
149 181