#include <kmime_util.h>
Public Types | |
enum | FormatType { CTime , Localized , Fancy , Iso , Custom } |
Public Member Functions | |
DateFormatter (FormatType fType=DateFormatter::Fancy) | |
FormatType | getFormat () const |
void | setFormat (FormatType t) |
TQString | dateString (time_t otime, const TQString &lang=TQString(), bool shortFormat=true, bool includeSecs=false) const |
TQString | dateString (const TQDateTime &dtime, const TQString &lang=TQString(), bool shortFormat=true, bool includeSecs=false) const |
void | setCustomFormat (const TQString &format) |
TQString | getCustomFormat () const |
TQCString | rfc2822 (time_t otime) const |
void | reset () |
Static Public Member Functions | |
static TQString | formatDate (DateFormatter::FormatType t, time_t time, const TQString &data=TQString(), bool shortFormat=true, bool includeSecs=false) |
static TQString | formatCurrentDate (DateFormatter::FormatType t, const TQString &data=TQString(), bool shortFormat=true, bool includeSecs=false) |
static TQCString | rfc2822FormatDate (time_t time) |
static bool | isDaylight () |
Protected Member Functions | |
TQString | fancy (time_t otime) const |
TQString | localized (time_t otime, bool shortFormat=true, bool includeSecs=false, const TQString &localeLanguage=TQString()) const |
TQString | cTime (time_t otime) const |
TQString | isoDate (time_t otime) const |
TQString | custom (time_t t) const |
TQCString | zone (time_t otime) const |
time_t | qdateToTimeT (const TQDateTime &dt) const |
Detailed Description
class abstracting date formatting
DateFormatter 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 194 of file kmime_util.h.
Constructor & Destructor Documentation
◆ DateFormatter()
KMime::DateFormatter::DateFormatter | ( | FormatType | fType = DateFormatter::Fancy | ) |
constructor
- Parameters
-
fType default format used by the class
Definition at line 463 of file kmime_util.cpp.
Member Function Documentation
◆ cTime()
|
protected |
returns string as formatted with ctime function
Definition at line 713 of file kmime_util.cpp.
◆ custom()
|
protected |
returns date formatted with the earlier given custom format
- Parameters
-
t time used for formatting
Definition at line 530 of file kmime_util.cpp.
◆ dateString() [1/2]
TQString KMime::DateFormatter::dateString | ( | const TQDateTime & | dtime, |
const TQString & | lang = TQString() , |
||
bool | shortFormat = true , |
||
bool | includeSecs = false |
||
) | const |
overloaded, does exactly what dateString does (it's slower)
Definition at line 509 of file kmime_util.cpp.
◆ dateString() [2/2]
TQString KMime::DateFormatter::dateString | ( | time_t | otime, |
const TQString & | lang = TQString() , |
||
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 TDELocale::formatDateTime includeSecs used only by the Localized format, is passed to TDELocale::formatDateTime
Definition at line 485 of file kmime_util.cpp.
◆ fancy()
|
protected |
returns fancy formatted date string
- Parameters
-
otime time to format
Definition at line 637 of file kmime_util.cpp.
◆ formatCurrentDate()
|
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 TDELocale::formatDateTime includeSecs used only by the Localized format, is passed to TDELocale::formatDateTime
Definition at line 745 of file kmime_util.cpp.
◆ formatDate()
|
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 TDELocale::formatDateTime includeSecs used only by the Localized format, is passed to TDELocale::formatDateTime
Definition at line 734 of file kmime_util.cpp.
◆ getFormat()
DateFormatter::FormatType KMime::DateFormatter::getFormat | ( | ) | const |
returns the currently set format
Definition at line 473 of file kmime_util.cpp.
◆ isoDate()
|
protected |
returns a string in the "%Y-%m-%d %H:%M:%S" format
Definition at line 719 of file kmime_util.cpp.
◆ localized()
|
protected |
returns localized formatted date string
- Parameters
-
otime time to format shortFormat includeSecs localeLanguage language used for formatting
Definition at line 689 of file kmime_util.cpp.
◆ reset()
void KMime::DateFormatter::reset | ( | ) |
resets the internal clock
Definition at line 728 of file kmime_util.cpp.
◆ rfc2822()
TQCString KMime::DateFormatter::rfc2822 | ( | time_t | otime | ) | const |
returns rfc2822 formatted string
- Parameters
-
otime time to use for formatting
Definition at line 516 of file kmime_util.cpp.
◆ rfc2822FormatDate()
|
static |
convenience function, same as rfc2822
Definition at line 756 of file kmime_util.cpp.
◆ setCustomFormat()
void KMime::DateFormatter::setCustomFormat | ( | const TQString & | format | ) |
makes the class use the custom format for date to string conversions.
Method accepts the same arguments as TQDateTime::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 550 of file kmime_util.cpp.
◆ setFormat()
void KMime::DateFormatter::setFormat | ( | FormatType | t | ) |
sets the currently used format
Definition at line 479 of file kmime_util.cpp.
◆ zone()
|
protected |
returns a string identifying the timezone (eg.
"-0500")
Definition at line 564 of file kmime_util.cpp.
The documentation for this class was generated from the following files: