libkmime

#include <kmime_util.h>

List of all members.

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

KMime::DateFormatter::DateFormatter ( FormatType  fType = DateFormatter::Fancy)

constructor

Parameters:
fTypedefault format used by the class

Definition at line 463 of file kmime_util.cpp.


Member Function Documentation

TQString KMime::DateFormatter::cTime ( time_t  otime) const [protected]

returns string as formatted with ctime function

Definition at line 713 of file kmime_util.cpp.

TQString KMime::DateFormatter::custom ( time_t  t) const [protected]

returns date formatted with the earlier given custom format

Parameters:
ttime used for formatting

Definition at line 530 of file kmime_util.cpp.

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:
otimetime to format
langused only by the Localized format, sets the used language
shortFormatused only by the Localized format, is passed to TDELocale::formatDateTime
includeSecsused only by the Localized format, is passed to TDELocale::formatDateTime

Definition at line 485 of file kmime_util.cpp.

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.

TQString KMime::DateFormatter::fancy ( time_t  otime) const [protected]

returns fancy formatted date string

Parameters:
otimetime to format

Definition at line 637 of file kmime_util.cpp.

TQString KMime::DateFormatter::formatCurrentDate ( DateFormatter::FormatType  t,
const TQString &  data = TQString(),
bool  shortFormat = true,
bool  includeSecs = false 
) [static]

convenience function, same as formatDate but returns the current time formatted

Parameters:
tspecifies the FormatType to use
datais either the format when FormatType is Custom, or language when FormatType is Localized
shortFormatused only by the Localized format, is passed to TDELocale::formatDateTime
includeSecsused only by the Localized format, is passed to TDELocale::formatDateTime

Definition at line 745 of file kmime_util.cpp.

TQString KMime::DateFormatter::formatDate ( DateFormatter::FormatType  t,
time_t  time,
const TQString &  data = TQString(),
bool  shortFormat = true,
bool  includeSecs = false 
) [static]

convenience function dateString

Parameters:
tspecifies the FormatType to use
timetime to format
datais either the format when FormatType is Custom, or language when FormatType is Localized
shortFormatused only by the Localized format, is passed to TDELocale::formatDateTime
includeSecsused only by the Localized format, is passed to TDELocale::formatDateTime

Definition at line 734 of file kmime_util.cpp.

DateFormatter::FormatType KMime::DateFormatter::getFormat ( ) const

returns the currently set format

Definition at line 473 of file kmime_util.cpp.

TQString KMime::DateFormatter::isoDate ( time_t  otime) const [protected]

returns a string in the "%Y-%m-%d %H:%M:%S" format

Definition at line 719 of file kmime_util.cpp.

TQString KMime::DateFormatter::localized ( time_t  otime,
bool  shortFormat = true,
bool  includeSecs = false,
const TQString &  localeLanguage = TQString() 
) const [protected]

returns localized formatted date string

Parameters:
otimetime to format
shortFormat
includeSecs
localeLanguagelanguage used for formatting

Definition at line 689 of file kmime_util.cpp.

resets the internal clock

Definition at line 728 of file kmime_util.cpp.

TQCString KMime::DateFormatter::rfc2822 ( time_t  otime) const

returns rfc2822 formatted string

Parameters:
otimetime to use for formatting

Definition at line 516 of file kmime_util.cpp.

TQCString KMime::DateFormatter::rfc2822FormatDate ( time_t  time) [static]

convenience function, same as rfc2822

Definition at line 756 of file kmime_util.cpp.

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:
formatthe custom format

Definition at line 550 of file kmime_util.cpp.

void KMime::DateFormatter::setFormat ( FormatType  t)

sets the currently used format

Definition at line 479 of file kmime_util.cpp.

TQCString KMime::DateFormatter::zone ( time_t  otime) const [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: