ktimezones.h
/*
This file is part of the KDE libraries
Copyright (c) 2005 S.R.Haque <srhaque@iee.org>.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KTIMEZONES_H
#define _KTIMEZONES_H
#include "kdelibs_export.h"
#include <qdatetime.h>
#include <qnamespace.h>
#include <qmap.h>
#include <qstring.h>
#include <ksharedptr.h>
class KTimezoneDetails;
class KTimezoneDetailsPrivate;
class KTimezonePrivate;
class KTimezonesPrivate;
class KDECORE_EXPORT KTimezoneSource :
public KShared
{
public:
KTimezoneSource(const QString &db);
virtual ~KTimezoneSource();
virtual QString db();
virtual bool parse(const QString &zone, KTimezoneDetails &dataReceiver) const;
private:
QString m_db;
};
class KDECORE_EXPORT KTimezone
{
public:
static const float UNKNOWN;
static bool isValidLatitude(float latitude);
static bool isValidLongitude(float longitude);
KTimezone(
KSharedPtr<KTimezoneSource> db, const QString &name,
const QString &countryCode = QString(), float latitude = UNKNOWN, float longitude = UNKNOWN,
const QString &comment = QString());
~KTimezone();
QString name() const;
QString countryCode() const;
float latitude() const;
float longitude() const;
int offset(Qt::TimeSpec basisSpec = Qt::UTC) const;
int offset(const QDateTime &dateTime) const;
QDateTime convert(const KTimezone *newZone, const QDateTime &dateTime) const;
QString comment() const;
bool parse(KTimezoneDetails &dataReceiver) const;
private:
KTimezone(const KTimezone&);
KTimezone& operator=(const KTimezone&);
KSharedPtr<KTimezoneSource> m_db;
QString m_name;
QString m_countryCode;
float m_latitude;
float m_longitude;
QString m_comment;
KTimezonePrivate *d;
};
class KDECORE_EXPORT KTimezoneDetails
{
public:
KTimezoneDetails();
virtual ~KTimezoneDetails();
virtual void parseEnded();
virtual void parseStarted();
virtual void gotHeader(
unsigned ttIsGmtCnt, unsigned ttIsStdCnt, unsigned leapCnt,
unsigned timeCnt, unsigned typeCnt, unsigned charCnt);
virtual void gotTransitionTime(int index, unsigned transitionTime);
virtual void gotLocalTimeIndex(int index, unsigned localTimeIndex);
virtual void gotLocalTime(int index, int gmtOff, bool isDst, unsigned abbrIndex);
virtual void gotAbbreviation(int index, const QString &abbr);
virtual void gotLeapAdjustment(int index, unsigned leapTime, unsigned leapSeconds);
virtual void gotIsStandard(int index, bool isStandard);
virtual void gotIsUTC(int index, bool isUTC);
private:
KTimezoneDetailsPrivate *d;
};
class KDECORE_EXPORT KTimezones
{
public:
KTimezones();
~KTimezones();
const KTimezone *local();
const KTimezone *zone(const QString &name);
typedef QMap<QString, KTimezone *> ZoneMap;
const ZoneMap allZones();
void add(KTimezone *zone);
private:
KTimezones(const KTimezones&);
KTimezones& operator=(const KTimezones&);
float convertCoordinate(const QString &coordinate);
QString m_zoneinfoDir;
ZoneMap *m_zones;
KTimezone *m_UTC;
KTimezonesPrivate *d;
};
#endif
KSharedPtr< KTimezoneSource >
KTimezones
The KTimezones class models a timezone database.
Definition: ktimezones.h:296
KTimezone
The KTimezone class contains core functions related to a timezone.
Definition: ktimezones.h:85
KTimezoneSource
The KTimezoneSource class contains information source-dependent functions related to a timezone...
Definition: ktimezones.h:51
KTimezone::UNKNOWN
static const float UNKNOWN
A representation for unknown locations; this is a float that does not represent a real latitude or lo...
Definition: ktimezones.h:92
KTimezoneDetails
The KTimezoneDetails class contains extended functions related to a timezone.
Definition: ktimezones.h:225
KShared
Reference counting for shared objects.
Definition: ksharedptr.h:40

KDE Home | KDE Accessibility Home | Description of Access Keys