timestring.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TIMESTRING_H_
00022 #define _TIMESTRING_H_
00023 #include <qdatetime.h>
00024 #include <qstring.h>
00025
00026
00027
00028
00029
00030 class DateFormat
00031 {
00032 public:
00033
00034 enum Order {
00035 DayMonthYear = 0x0111,
00036 MonthDayYear = 0x010A,
00037 YearMonthDay = 0x0054
00038 };
00039
00040 DateFormat(QChar s = '/', Order so = MonthDayYear) : _shortOrder(so),
00041 _longOrder(so), _shortSeparator(s) { }
00042 DateFormat(QChar s, Order so, Order lo) : _shortOrder(so),
00043 _longOrder(lo), _shortSeparator(s) { }
00044 DateFormat(const DateFormat &o) : _shortOrder(o._shortOrder),
00045 _longOrder(o._longOrder), _shortSeparator(o._shortSeparator) { }
00046
00047 bool operator==(const DateFormat &o)
00048 {
00049 if (o._shortOrder == _shortOrder && o._longOrder == _longOrder &&
00050 o._shortSeparator == _shortSeparator)
00051 return TRUE;
00052 return FALSE;
00053 }
00054
00055
00056 enum Verbosity {
00057 shortNumber = 0x01,
00058 longNumber = 0x02,
00059
00060 padNumber = 0x04,
00061
00062 shortWord = 0x08,
00063 longWord = 0x10,
00064
00065 showWeekDay = 0x20
00066 };
00067
00068 QString toNumberString() const;
00069 QString toWordString() const;
00070
00071 QString numberDate(const QDate &d, int v = 0) const;
00072 QString wordDate(const QDate &d, int v = 0) const;
00073
00074 #ifndef QT_NO_DATASTREAM
00075 void load(QDataStream&);
00076 void save(QDataStream&) const;
00077 #endif
00078
00079 QChar separator() const { return _shortSeparator; };
00080 Order shortOrder() const { return _shortOrder; };
00081 Order longOrder() const { return _longOrder; };
00082
00083 private:
00084 Order _shortOrder;
00085 Order _longOrder;
00086 QChar _shortSeparator;
00087 };
00088
00089 #ifndef QT_NO_DATASTREAM
00090 QDataStream &operator<<(QDataStream &s, const DateFormat&df);
00091 QDataStream &operator>>(QDataStream &s, DateFormat&df);
00092 #endif
00093
00094 class TimeString
00095 {
00096 public:
00097
00098
00099
00100
00101
00102 static QString shortDate( const QDate &d )
00103 { return shortDate( d, currentDateFormat() ); }
00104 static QString dateString( const QDate &d )
00105 { return dateString( d, currentDateFormat() ); }
00106 static QString longDateString( const QDate &d )
00107 { return longDateString( d, currentDateFormat() ); }
00108 static QString dateString( const QDateTime &dt, bool ampm, bool seconds )
00109 { return dateString( dt, ampm, seconds, currentDateFormat() ); }
00110
00111 static QString dateString( const QDateTime &t, bool ampm = false );
00112 static QString timeString( const QTime &t, bool ampm, bool seconds );
00113 static QString timeString( const QTime &t, bool ampm = false );
00114 static QString shortTime( bool ampm, bool seconds );
00115 static QString shortTime( bool ampm = false );
00116
00117 static QString numberDateString( const QDate &d, DateFormat );
00118 static QString numberDateString( const QDate &d )
00119 { return numberDateString( d, currentDateFormat() ); }
00120 static QString longNumberDateString( const QDate &d, DateFormat );
00121 static QString longNumberDateString( const QDate &d )
00122 { return longNumberDateString( d, currentDateFormat() ); }
00123
00124 static QString shortDate( const QDate &, DateFormat );
00125 static QString dateString( const QDate &, DateFormat );
00126 static QString longDateString( const QDate &, DateFormat );
00127
00128 static DateFormat currentDateFormat();
00129
00130 private:
00131 static QString dateString( const QDateTime &t, bool ampm, bool seconds, DateFormat );
00132
00133
00134 };
00135
00136 #endif
This file is part of the documentation for OPIE Version 1.5.5.