/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/

#ifndef QTOPIA_TIMEZ0NE_H
#define QTOPIA_TIMEZ0NE_H

#include <qstring.h>
#include <qdatetime.h>
#include <qstrlist.h>
#include <qdatastream.h>
#include <qtopia/qpeglobal.h>

class TimeZonePrivate;
class QTOPIA_EXPORT TimeZone
{
public:
    TimeZone();
    TimeZone( const char *id );
    TimeZone( const TimeZone & );
    ~TimeZone();

    bool isValid() const;

    void setId( const char *id );

    TimeZone &operator=( const TimeZone &);
    bool operator==( const TimeZone &) const;
    bool operator!=( const TimeZone &) const;

    /*! returns QDateTime in this timezone */
    QDateTime fromTime_t( uint t ) const;
    uint toTime_t( const QDateTime &thisT ) const;

    /** /a dt is in this time zone */
    QDateTime toUtc( const QDateTime &thisT ) const;
    QDateTime fromUtc( const QDateTime &utc ) const;

    QDateTime toCurrent( const QDateTime &thisT ) const;
    QDateTime fromCurrent( const QDateTime &curT ) const;

    // convert the /a dt which is in the timezone /a tz to "this" timezone
    QDateTime convert( const QDateTime &dt, const TimeZone &dtTz ) const;

    static TimeZone current();
    static TimeZone utc();
    static QDateTime utcDateTime();

    /** in seconds */
    int lat() const;
    /** in seconds */
    int lon() const;

    QCString dstAbbreviation() const;
    QCString standardAbbreviation() const;

    QCString latStr() const;
    QCString lonStr() const;

    QString description() const;
    QString area() const;
    QString city() const;
    QCString countryCode();
    QCString id() const;
    int distance( const TimeZone &e ) const;

    static QStrList ids();

    /* for debugging purposes */
    void dump() const;

private:
    TimeZonePrivate *d;
};

QTOPIA_EXPORT QDataStream &operator<<( QDataStream &, const TimeZone & );
QTOPIA_EXPORT QDataStream &operator>>( QDataStream &, TimeZone & );

#endif
