KDECore
KSystemTimeZones Class Reference
[Time zone classes]
The KSystemTimeZones class represents the system time zone database, consisting of a collection of individual system time zone definitions, indexed by name.
More...
#include <ksystemtimezone.h>

Public Member Functions | |
~KSystemTimeZones () | |
Static Public Member Functions | |
static KTimeZone | local () |
static KTimeZone | readZone (const QString &name) |
static KTimeZones * | timeZones () |
static KTimeZone | zone (const QString &name) |
static QString | zoneinfoDir () |
static const KTimeZones::ZoneMap | zones () |
Detailed Description
The KSystemTimeZones class represents the system time zone database, consisting of a collection of individual system time zone definitions, indexed by name.Each individual time zone is defined in a KSystemTimeZone instance. Additional time zones (of any class derived from KTimeZone) may be added if desired.
At initialisation, KSystemTimeZones reads the zone.tab file to obtain the list of system time zones, and creates a KSystemTimeZone instance for each one.
Note that KSystemTimeZones is not derived from KTimeZones, but instead contains a KTimeZones instance which holds the system time zone database. Convenience static methods are defined to access its data, or alternatively you can access the KTimeZones instance directly via the timeZones() method.
As an example, find the local time in Oman corresponding to the local system time of 12:15:00 on 13th November 1999:
QDateTime sampleTime(QDate(1999,11,13), QTime(12,15,0), Qt::LocalTime); KTimeZone local = KSystemTimeZones::local(); KTimeZone oman = KSystemTimeZones::zone("Asia/Muscat"); QDateTime omaniTime = local.convert(oman, sampleTime);
- Warning:
- The time zones in the KSystemTimeZones collection are by default instances of the KSystemTimeZone class, which uses the standard system libraries to access time zone data, and whose functionality is limited to what these libraries provide. For guaranteed accuracy for past time change dates and time zone abbreviations, you should use KSystemTimeZones::readZone() or the KTzfileTimeZone class instead, which provide accurate information from the time zone definition files (but are likely to incur more overhead).
Definition at line 82 of file ksystemtimezone.h.
Constructor & Destructor Documentation
KSystemTimeZones::~KSystemTimeZones | ( | ) |
Definition at line 171 of file ksystemtimezone.cpp.
Member Function Documentation
KTimeZone KSystemTimeZones::local | ( | ) | [static] |
Returns the current local system time zone.
The idea of this routine is to provide a robust lookup of the local time zone. The problem is that on Unix systems, there are a variety of mechanisms for setting this information, and no well defined way of getting it. For example, if you set your time zone to "Europe/London", then the tzname[] maintained by tzset() typically returns { "GMT", "BST" }. The point of this routine is to actually return "Europe/London" (or rather, the corresponding KTimeZone).
Note that depending on how the system stores its current time zone, this routine may return a synonym of the expected time zone. For example, "Europe/London", "Europe/Guernsey" and some other time zones are all identical and there may be no way for the routine to distinguish which of these is the correct zone name from the user's point of view.
- Returns:
- local system time zone. If necessary, we will use a series of heuristics which end by returning UTC. We will never return NULL. Note that if UTC is returned as a default, it may not belong to the the collection returned by KSystemTimeZones::zones().
Definition at line 175 of file ksystemtimezone.cpp.
Returns the time zone with the given name, containing the full time zone definition read directly from the system time zone database.
This may incur a higher overhead than zone(), but will provide whatever historical data the system holds.
- Parameters:
-
name name of time zone
- Returns:
- time zone (usually a KTzfileTimeZone instance), or invalid if not found
- See also:
- zone()
Definition at line 192 of file ksystemtimezone.cpp.
KTimeZones * KSystemTimeZones::timeZones | ( | ) | [static] |
Returns the unique KTimeZones instance containing the system time zones collection.
It is first created if it does not already exist.
- Returns:
- time zones.
Definition at line 187 of file ksystemtimezone.cpp.
Returns the time zone with the given name.
The time zone definition is obtained using system library calls, and may not contain historical data. If you need historical time change data, use the potentially slower method readZone().
- Parameters:
-
name name of time zone
- Returns:
- time zone (usually a KSystemTimeZone instance), or invalid if not found
- See also:
- readZone()
Definition at line 202 of file ksystemtimezone.cpp.
QString KSystemTimeZones::zoneinfoDir | ( | ) | [static] |
Returns the location of the system time zone zoneinfo database.
- Returns:
- path of directory containing the zoneinfo database
Definition at line 181 of file ksystemtimezone.cpp.
const KTimeZones::ZoneMap KSystemTimeZones::zones | ( | ) | [static] |
Returns all the time zones defined in this collection.
- Returns:
- time zone collection
Definition at line 197 of file ksystemtimezone.cpp.
The documentation for this class was generated from the following files: