• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KMIME Library

KMime::DateFormatter

KMime::DateFormatter Class Reference

A class for abstracting date formatting. More...

#include <kmime_dateformatter.h>

List of all members.


Public Types

enum  FormatType {
  CTime, Localized, Fancy, Iso,
  Rfc, Custom
}

Public Member Functions

QString customFormat () const
 DateFormatter (FormatType ftype=DateFormatter::Fancy)
QString dateString (const QDateTime &dtime, const QString &lang=QString(), bool shortFormat=true, bool includeSecs=false) const
QString dateString (time_t t, const QString &lang=QString(), bool shortFormat=true, bool includeSecs=false) const
FormatType format () const
void reset ()
void setCustomFormat (const QString &format)
void setFormat (FormatType ftype)
 ~DateFormatter ()

Static Public Member Functions

static QString formatCurrentDate (DateFormatter::FormatType ftype, const QString &data=QString(), bool shortFormat=true, bool includeSecs=false)
static QString formatDate (DateFormatter::FormatType ftype, time_t t, const QString &data=QString(), bool shortFormat=true, bool includeSecs=false)
static bool isDaylight ()

Protected Member Functions

QString cTime (time_t t) const
QString custom (time_t t) const
QString fancy (time_t t) const
QString isoDate (time_t t) const
QString localized (time_t t, bool shortFormat=true, bool includeSecs=false, const QString &lang=QString()) const
time_t qdateToTimeT (const QDateTime &dt) const
QString rfc2822 (time_t t) const
QByteArray zone (time_t t) const

Detailed Description

A class for abstracting date formatting.

This class deals with different kinds of date display formats. The formats supported include:

  • fancy "Today 02:08:35"
  • ctime as with the ctime function, eg. "Sun Mar 31 02:08:35 2002"
  • localized according to the control center setting, eg. "2002-03-31 02:08"
  • iso according to the ISO8601 standard, eg. "2002-03-31 02:08:35"
  • rfc according to RFC2822 (Section 3.3), eg. "Sun, 31 Mar 2002 02:08:35 -0500"
  • custom "whatever you like"

Definition at line 70 of file kmime_dateformatter.h.


Member Enumeration Documentation

enum KMime::DateFormatter::FormatType

The different types of date formats.

Enumerator:
CTime  ctime "Sun Mar 31 02:08:35 2002"
Localized  localized "2002-03-31 02:08"
Fancy  fancy "Today 02:08:35"
Iso  iso "2002-03-31 02:08:35"
Rfc  rfc "Sun, 31 Mar 2002 02:08:35 -0500"
Custom  custom "whatever you like"

Definition at line 76 of file kmime_dateformatter.h.


Constructor & Destructor Documentation

DateFormatter::DateFormatter ( FormatType  ftype = DateFormatter::Fancy  )  [explicit]

Constructs a date formatter with a default FormatType.

Parameters:
ftype is the default FormatType to use.

Definition at line 51 of file kmime_dateformatter.cpp.

DateFormatter::~DateFormatter (  ) 

Destroys the date formatter.

Definition at line 56 of file kmime_dateformatter.cpp.


Member Function Documentation

QString DateFormatter::cTime ( time_t  t  )  const [protected]

Returns a QString containing the specified time_t t formatted with the ctime() function.

Parameters:
t is the time_t to use for formatting.

Definition at line 289 of file kmime_dateformatter.cpp.

QString DateFormatter::custom ( time_t  t  )  const [protected]

Returns a QString containing the specified time_t t formatted with a previously specified custom format.

Parameters:
t time used for formatting

Definition at line 115 of file kmime_dateformatter.cpp.

QString DateFormatter::customFormat (  )  const

Returns the custom format string.

See also:
setCustomFormat().

Definition at line 141 of file kmime_dateformatter.cpp.

QString DateFormatter::dateString ( const QDateTime &  dtime,
const QString &  lang = QString(),
bool  shortFormat = true,
bool  includeSecs = false 
) const

Constructs a formatted date string from QDateTime dtime.

Parameters:
dtime is the QDateTime to use for formatting.
lang is the language, only used if FormatType is Localized.
shortFormat if true, create the short version of the date string, only used if FormatType is Localized.
includeSecs if true, include the seconds field in the date string, only used if FormatType is Localized.
Returns:
a QString containing the formatted date.

Definition at line 96 of file kmime_dateformatter.cpp.

QString DateFormatter::dateString ( time_t  t,
const QString &  lang = QString(),
bool  shortFormat = true,
bool  includeSecs = false 
) const

Constructs a formatted date string from time_t t.

Parameters:
t is the time_t to use for formatting.
lang is the language, only used if FormatType is Localized.
shortFormat if true, create the short version of the date string, only used if FormatType is Localized.
includeSecs if true, include the seconds field in the date string, only used if FormatType is Localized.
Returns:
a QString containing the formatted date.

Definition at line 70 of file kmime_dateformatter.cpp.

QString DateFormatter::fancy ( time_t  t  )  const [protected]

Returns a QString containing the specified time_t t formatted using the Fancy FormatType.

Parameters:
t is the time_t to use for formatting.

Definition at line 220 of file kmime_dateformatter.cpp.

DateFormatter::FormatType DateFormatter::format (  )  const

Returns the FormatType currently set.

See also:
setFormat().

Definition at line 60 of file kmime_dateformatter.cpp.

QString DateFormatter::formatCurrentDate ( DateFormatter::FormatType  ftype,
const QString &  data = QString(),
bool  shortFormat = true,
bool  includeSecs = false 
) [static]

Convenience function, same as formatDate() but returns the current time formatted.

Parameters:
ftype is the FormatType to use.
data is either the format when FormatType is Custom, or language when FormatType is Localized.
shortFormat if true, create the short version of the date string, only used if FormatType is Localized.
includeSecs if true, include the seconds field in the date string, only used if FormatType is Localized.
Returns:
a QString containing the formatted date.

Definition at line 317 of file kmime_dateformatter.cpp.

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

Convenience function dateString.

Parameters:
ftype is the FormatType to use.
t is the time_t to use for formatting.
data is either the format when FormatType is Custom, or language when FormatType is Localized.
shortFormat if true, create the short version of the date string, only used if FormatType is Localized.
includeSecs if true, include the seconds field in the date string, only used if FormatType is Localized.
Returns:
a QString containing the formatted date.

Definition at line 306 of file kmime_dateformatter.cpp.

bool DateFormatter::isDaylight (  )  [static]

Returns true if the current time is on daylight savings time; else false.

Definition at line 327 of file kmime_dateformatter.cpp.

QString DateFormatter::isoDate ( time_t  t  )  const [protected]

Returns a QString containing the specified time_t t in the "%Y-%m-%d %H:%M:%S" Iso FormatType.

Parameters:
t is the time_t to use for formatting.

Definition at line 294 of file kmime_dateformatter.cpp.

QString DateFormatter::localized ( time_t  t,
bool  shortFormat = true,
bool  includeSecs = false,
const QString &  lang = QString() 
) const [protected]

Returns a QString containing the specified time_t t formatted using the Localized FormatType.

Parameters:
t is the time_t to use for formatting.
shortFormat if true, create the short version of the date string.
includeSecs if true, include the seconds field in the date string.
lang is a QString containing the language to use.

Definition at line 269 of file kmime_dateformatter.cpp.

time_t DateFormatter::qdateToTimeT ( const QDateTime &  dt  )  const [protected]

Converts QDateTime dt to a time_t value.

Parameters:
dt is the QDateTime to be converted.
Returns:
the time_t equivalent of the specified QDateTime.

Definition at line 207 of file kmime_dateformatter.cpp.

void DateFormatter::reset (  ) 

Resets the internal clock.

Definition at line 301 of file kmime_dateformatter.cpp.

QString DateFormatter::rfc2822 ( time_t  t  )  const [protected]

Returns a QString containing the specified time_t t in the Rfc FormatType.

Parameters:
t is the time_t to use for formatting.

Definition at line 102 of file kmime_dateformatter.cpp.

void DateFormatter::setCustomFormat ( const QString &  format  ) 

Sets the custom format for date to string conversions to format.

This method accepts the same arguments as QDateTime::toString(), but also supports the "Z" expression which is substituted with the RFC2822 (Section 3.3) style numeric timezone (-0500).

Parameters:
format is a QString containing the custom format.
See also:
QDateTime::toString(), customFormat().

Definition at line 135 of file kmime_dateformatter.cpp.

void DateFormatter::setFormat ( FormatType  ftype  ) 

Sets the date format to ftype.

Parameters:
ftype is the FormatType.
See also:
format().

Definition at line 65 of file kmime_dateformatter.cpp.

QByteArray DateFormatter::zone ( time_t  t  )  const [protected]

Returns a QString that identifies the timezone (eg.

"-0500") of the specified time_t t.

Parameters:
t time to compute timezone from.

Definition at line 146 of file kmime_dateformatter.cpp.


The documentation for this class was generated from the following files:
  • kmime_dateformatter.h
  • kmime_dateformatter.cpp

KMIME Library

Skip menu "KMIME Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal