KMIME Library
kmime_dateformatter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00047 #ifndef __KMIME_DATEFORMATTER_H__
00048 #define __KMIME_DATEFORMATTER_H__
00049
00050 #include <time.h>
00051 #include <QtCore/QDateTime>
00052 #include <QtCore/QString>
00053 #include "kmime_export.h"
00054
00055 namespace KMime {
00056
00070 class KMIME_EXPORT DateFormatter
00071 {
00072 public:
00076 enum FormatType {
00077 CTime,
00078 Localized,
00079 Fancy,
00080 Iso,
00081 Rfc,
00082 Custom
00083 };
00084
00090 explicit DateFormatter( FormatType ftype=DateFormatter::Fancy );
00091
00095 ~DateFormatter();
00096
00102 FormatType format() const;
00103
00111 void setFormat( FormatType ftype );
00112
00125 QString dateString( time_t t, const QString &lang=QString(),
00126 bool shortFormat=true, bool includeSecs=false ) const;
00127
00140 QString dateString( const QDateTime &dtime, const QString &lang=QString(),
00141 bool shortFormat=true, bool includeSecs=false ) const;
00142
00153 void setCustomFormat( const QString &format );
00154
00160 QString customFormat() const;
00161
00167 void reset();
00168
00169
00184 static QString formatDate( DateFormatter::FormatType ftype, time_t t,
00185 const QString &data=QString(),
00186 bool shortFormat=true,
00187 bool includeSecs=false );
00188
00203 static QString formatCurrentDate( DateFormatter::FormatType ftype,
00204 const QString &data=QString(),
00205 bool shortFormat=true,
00206 bool includeSecs=false );
00207
00211 static bool isDaylight();
00212
00213 protected:
00220 QString fancy( time_t t ) const ;
00221
00231 QString localized( time_t t, bool shortFormat=true,
00232 bool includeSecs=false,
00233 const QString &lang=QString() ) const;
00234
00241 QString cTime( time_t t ) const;
00242
00249 QString isoDate( time_t t ) const;
00250
00257 QString rfc2822( time_t t ) const;
00258
00265 QString custom( time_t t ) const;
00266
00273 QByteArray zone( time_t t ) const;
00274
00281 time_t qdateToTimeT( const QDateTime &dt ) const;
00282
00283 private:
00284
00285 FormatType mFormat;
00286 mutable time_t mTodayOneSecondBeforeMidnight;
00287 mutable QDateTime mUnused;
00288 QString mCustomFormat;
00289 static int mDaylight;
00290
00291 };
00292
00293 }
00294
00295 #endif