libkmime
KMime::DateFormatter Class Reference
#include <kmime_util.h>
Detailed Description
class abstracting date formattingDateFormatter deals with different kinds of date display formats. The formats supported by the class include:
- fancy "Today 02:08:35"
- ctime "Sun Mar 31 02:08:35 2002"
- localized "2002-03-31 02:08"
- iso "2002-03-31 02:08:35"
- rfc2822 "Sun, 31 Mar 2002 02:08:35 -0500"
- custom "whatever you like"
Definition at line 187 of file kmime_util.h.
Public Types | |
enum | FormatType { CTime, Localized, Fancy, Iso, Custom } |
Public Member Functions | |
DateFormatter (FormatType fType=DateFormatter::Fancy) | |
~DateFormatter () | |
FormatType | getFormat () const |
void | setFormat (FormatType t) |
QString | dateString (time_t otime, const QString &lang=QString::null, bool shortFormat=true, bool includeSecs=false) const |
QString | dateString (const QDateTime &dtime, const QString &lang=QString::null, bool shortFormat=true, bool includeSecs=false) const |
void | setCustomFormat (const QString &format) |
QString | getCustomFormat () const |
QCString | rfc2822 (time_t otime) const |
void | reset () |
Static Public Member Functions | |
static QString | formatDate (DateFormatter::FormatType t, time_t time, const QString &data=QString::null, bool shortFormat=true, bool includeSecs=false) |
static QString | formatCurrentDate (DateFormatter::FormatType t, const QString &data=QString::null, bool shortFormat=true, bool includeSecs=false) |
static QCString | rfc2822FormatDate (time_t time) |
static bool | isDaylight () |
Protected Member Functions | |
QString | fancy (time_t otime) const |
QString | localized (time_t otime, bool shortFormat=true, bool includeSecs=false, const QString &localeLanguage=QString::null) const |
QString | cTime (time_t otime) const |
QString | isoDate (time_t otime) const |
QString | custom (time_t t) const |
QCString | zone (time_t otime) const |
time_t | qdateToTimeT (const QDateTime &dt) const |
Constructor & Destructor Documentation
KMime::DateFormatter::DateFormatter | ( | FormatType | fType = DateFormatter::Fancy |
) |
constructor
- Parameters:
-
fType default format used by the class
Definition at line 478 of file kmime_util.cpp.
Member Function Documentation
DateFormatter::FormatType KMime::DateFormatter::getFormat | ( | ) | const |
void KMime::DateFormatter::setFormat | ( | FormatType | t | ) |
QString KMime::DateFormatter::dateString | ( | time_t | otime, | |
const QString & | lang = QString::null , |
|||
bool | shortFormat = true , |
|||
bool | includeSecs = false | |||
) | const |
returns formatted date string in a currently set format.
- Parameters:
-
otime time to format lang used only by the Localized format, sets the used language shortFormat used only by the Localized format, is passed to KLocale::formatDateTime includeSecs used only by the Localized format, is passed to KLocale::formatDateTime
Definition at line 500 of file kmime_util.cpp.
QString KMime::DateFormatter::dateString | ( | const QDateTime & | dtime, | |
const QString & | lang = QString::null , |
|||
bool | shortFormat = true , |
|||
bool | includeSecs = false | |||
) | const |
overloaded, does exactly what dateString does (it's slower)
Definition at line 524 of file kmime_util.cpp.
void KMime::DateFormatter::setCustomFormat | ( | const QString & | format | ) |
makes the class use the custom format for date to string conversions.
Method accepts the same arguments as QDateTime::toString method and adds "Z" expression which is substituted with the RFC-822 style numeric timezone (-0500)
- Parameters:
-
format the custom format
Definition at line 565 of file kmime_util.cpp.
QCString KMime::DateFormatter::rfc2822 | ( | time_t | otime | ) | const |
returns rfc2822 formatted string
- Parameters:
-
otime time to use for formatting
Definition at line 531 of file kmime_util.cpp.
void KMime::DateFormatter::reset | ( | ) |
QString KMime::DateFormatter::formatDate | ( | DateFormatter::FormatType | t, | |
time_t | time, | |||
const QString & | data = QString::null , |
|||
bool | shortFormat = true , |
|||
bool | includeSecs = false | |||
) | [static] |
convenience function dateString
- Parameters:
-
t specifies the FormatType to use time time to format data is either the format when FormatType is Custom, or language when FormatType is Localized shortFormat used only by the Localized format, is passed to KLocale::formatDateTime includeSecs used only by the Localized format, is passed to KLocale::formatDateTime
Definition at line 749 of file kmime_util.cpp.
QString KMime::DateFormatter::formatCurrentDate | ( | DateFormatter::FormatType | t, | |
const QString & | data = QString::null , |
|||
bool | shortFormat = true , |
|||
bool | includeSecs = false | |||
) | [static] |
convenience function, same as formatDate but returns the current time formatted
- Parameters:
-
t specifies the FormatType to use data is either the format when FormatType is Custom, or language when FormatType is Localized shortFormat used only by the Localized format, is passed to KLocale::formatDateTime includeSecs used only by the Localized format, is passed to KLocale::formatDateTime
Definition at line 760 of file kmime_util.cpp.
QCString KMime::DateFormatter::rfc2822FormatDate | ( | time_t | time | ) | [static] |
QString KMime::DateFormatter::fancy | ( | time_t | otime | ) | const [protected] |
returns fancy formatted date string
- Parameters:
-
otime time to format
Definition at line 652 of file kmime_util.cpp.
QString KMime::DateFormatter::localized | ( | time_t | otime, | |
bool | shortFormat = true , |
|||
bool | includeSecs = false , |
|||
const QString & | localeLanguage = QString::null | |||
) | const [protected] |
returns localized formatted date string
- Parameters:
-
otime time to format shortFormat includeSecs localeLanguage language used for formatting
Definition at line 704 of file kmime_util.cpp.
QString KMime::DateFormatter::cTime | ( | time_t | otime | ) | const [protected] |
QString KMime::DateFormatter::isoDate | ( | time_t | otime | ) | const [protected] |
QString KMime::DateFormatter::custom | ( | time_t | t | ) | const [protected] |
returns date formatted with the earlier given custom format
- Parameters:
-
t time used for formatting
Definition at line 545 of file kmime_util.cpp.
QCString KMime::DateFormatter::zone | ( | time_t | otime | ) | const [protected] |
returns a string identifying the timezone (eg.
"-0500")
Definition at line 579 of file kmime_util.cpp.
The documentation for this class was generated from the following files: