libkmime

KMime::DateFormatter Class Reference

class abstracting date formatting More...

#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::null, bool shortFormat=true, bool includeSecs=false) const
TQString dateString (const TQDateTime &dtime, const TQString &lang=TQString::null, 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::null, bool shortFormat=true, bool includeSecs=false)
static TQString formatCurrentDate (DateFormatter::FormatType t, const TQString &data=TQString::null, 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::null) 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:
fType default format used by the class

Definition at line 488 of file kmime_util.cpp.


Member Function Documentation

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

returns the currently set format

Definition at line 498 of file kmime_util.cpp.

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

sets the currently used format

Definition at line 504 of file kmime_util.cpp.

QString KMime::DateFormatter::dateString ( time_t  otime,
const TQString &  lang = TQString::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 510 of file kmime_util.cpp.

QString KMime::DateFormatter::dateString ( const TQDateTime &  dtime,
const TQString &  lang = TQString::null,
bool  shortFormat = true,
bool  includeSecs = false 
) const

overloaded, does exactly what dateString does (it's slower)

Definition at line 534 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:
format the custom format

Definition at line 575 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 541 of file kmime_util.cpp.

void KMime::DateFormatter::reset (  ) 

resets the internal clock

Definition at line 753 of file kmime_util.cpp.

QString KMime::DateFormatter::formatDate ( DateFormatter::FormatType  t,
time_t  time,
const TQString &  data = TQString::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 759 of file kmime_util.cpp.

QString KMime::DateFormatter::formatCurrentDate ( DateFormatter::FormatType  t,
const TQString &  data = TQString::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 770 of file kmime_util.cpp.

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

convenience function, same as rfc2822

Definition at line 781 of file kmime_util.cpp.

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

returns fancy formatted date string

Parameters:
otime time to format

Definition at line 662 of file kmime_util.cpp.

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

returns localized formatted date string

Parameters:
otime time to format
shortFormat 
includeSecs 
localeLanguage language used for formatting

Definition at line 714 of file kmime_util.cpp.

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

returns string as formatted with ctime function

Definition at line 738 of file kmime_util.cpp.

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

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

Definition at line 744 of file kmime_util.cpp.

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 555 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 589 of file kmime_util.cpp.


The documentation for this class was generated from the following files: