libkdenetwork Library API Documentation

KMime::DateFormatter Class Reference

class abstracting date formatting More...

#include <kmime_util.h>

Collaboration diagram for KMime::DateFormatter:

Collaboration graph
[legend]
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)
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

Detailed Description

class abstracting date formatting

DateFormatter deals with different kinds of date display formats. The formats supported by the class include:

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


Member Function Documentation

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

returns the currently set format

Definition at line 486 of file kmime_util.cpp.

void KMime::DateFormatter::setFormat FormatType  t  ) 
 

sets the currently used format

Definition at line 492 of file kmime_util.cpp.

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

References cTime(), custom(), fancy(), isoDate(), and localized().

Referenced by dateString(), formatCurrentDate(), and formatDate().

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

References dateString().

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

Referenced by formatCurrentDate(), and formatDate().

QCString KMime::DateFormatter::rfc2822 time_t  otime  )  const
 

returns rfc2822 formatted string

Parameters:
otime time to use for formatting

Definition at line 529 of file kmime_util.cpp.

References zone().

Referenced by rfc2822FormatDate().

void KMime::DateFormatter::reset  ) 
 

resets the internal clock

Definition at line 740 of file kmime_util.cpp.

QString KMime::DateFormatter::formatDate DateFormatter::FormatType  t,
time_t  time,
const QString data = QString::null,
bool  shortFormat = true,
bool  includeSecs = false
[static]
 

convenience function

See also:
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 746 of file kmime_util.cpp.

References dateString(), and setCustomFormat().

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

References dateString(), and setCustomFormat().

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

convenience function, same as rfc2822

Definition at line 768 of file kmime_util.cpp.

References rfc2822().

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

returns fancy formatted date string

Parameters:
otime time to format

Definition at line 650 of file kmime_util.cpp.

Referenced by dateString().

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

Referenced by dateString().

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

returns string as formatted with ctime function

Definition at line 725 of file kmime_util.cpp.

Referenced by dateString().

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

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

Definition at line 731 of file kmime_util.cpp.

Referenced by dateString().

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

References zone().

Referenced by dateString().

QCString KMime::DateFormatter::zone time_t  otime  )  const [protected]
 

returns a string identifying the timezone (eg.

"-0500")

Definition at line 577 of file kmime_util.cpp.

Referenced by custom(), and rfc2822().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 25 11:17:09 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003