Blame qtools/qdatetime.h

Packit Service 50c9f2
/****************************************************************************
Packit Service 50c9f2
** 
Packit Service 50c9f2
**
Packit Service 50c9f2
** Definition of date and time classes
Packit Service 50c9f2
**
Packit Service 50c9f2
** Created : 940124
Packit Service 50c9f2
**
Packit Service 50c9f2
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
Packit Service 50c9f2
**
Packit Service 50c9f2
** This file is part of the tools module of the Qt GUI Toolkit.
Packit Service 50c9f2
**
Packit Service 50c9f2
** This file may be distributed under the terms of the Q Public License
Packit Service 50c9f2
** as defined by Trolltech AS of Norway and appearing in the file
Packit Service 50c9f2
** LICENSE.QPL included in the packaging of this file.
Packit Service 50c9f2
**
Packit Service 50c9f2
** This file may be distributed and/or modified under the terms of the
Packit Service 50c9f2
** GNU General Public License version 2 as published by the Free Software
Packit Service 50c9f2
** Foundation and appearing in the file LICENSE.GPL included in the
Packit Service 50c9f2
** packaging of this file.
Packit Service 50c9f2
**
Packit Service 50c9f2
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
Packit Service 50c9f2
** licenses may use this file in accordance with the Qt Commercial License
Packit Service 50c9f2
** Agreement provided with the Software.
Packit Service 50c9f2
**
Packit Service 50c9f2
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
Packit Service 50c9f2
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Packit Service 50c9f2
**
Packit Service 50c9f2
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
Packit Service 50c9f2
**   information about Qt Commercial License Agreements.
Packit Service 50c9f2
** See http://www.trolltech.com/qpl/ for QPL licensing information.
Packit Service 50c9f2
** See http://www.trolltech.com/gpl/ for GPL licensing information.
Packit Service 50c9f2
**
Packit Service 50c9f2
** Contact info@trolltech.com if any conditions of this licensing are
Packit Service 50c9f2
** not clear to you.
Packit Service 50c9f2
**
Packit Service 50c9f2
**********************************************************************/
Packit Service 50c9f2
Packit Service 50c9f2
#ifndef QDATETIME_H
Packit Service 50c9f2
#define QDATETIME_H
Packit Service 50c9f2
Packit Service 50c9f2
#ifndef QT_H
Packit Service 50c9f2
#include "qstring.h"
Packit Service 50c9f2
#endif // QT_H
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
/*****************************************************************************
Packit Service 50c9f2
  QDate class
Packit Service 50c9f2
 *****************************************************************************/
Packit Service 50c9f2
Packit Service 50c9f2
class Q_EXPORT QDate
Packit Service 50c9f2
{
Packit Service 50c9f2
public:
Packit Service 50c9f2
    QDate()  { jd=0; }				// set null date
Packit Service 50c9f2
    QDate( int y, int m, int d );		// set date
Packit Service 50c9f2
    virtual ~QDate() {}
Packit Service 50c9f2
Packit Service 50c9f2
    bool   isNull()	 const { return jd == 0; }
Packit Service 50c9f2
    bool   isValid()	 const;			// valid date
Packit Service 50c9f2
Packit Service 50c9f2
    int	   year()	 const;			// 1752..
Packit Service 50c9f2
    int	   month()	 const;			// 1..12
Packit Service 50c9f2
    int	   day()	 const;			// 1..31
Packit Service 50c9f2
    int	   dayOfWeek()	 const;			// 1..7 (monday==1)
Packit Service 50c9f2
    int	   dayOfYear()	 const;			// 1..365
Packit Service 50c9f2
    int	   daysInMonth() const;			// 28..31
Packit Service 50c9f2
    int	   daysInYear()	 const;			// 365 or 366
Packit Service 50c9f2
Packit Service 50c9f2
    virtual QString monthName( int month ) const;
Packit Service 50c9f2
    virtual QString dayName( int weekday ) const;
Packit Service 50c9f2
Packit Service 50c9f2
    QString toString()	 const;
Packit Service 50c9f2
Packit Service 50c9f2
    bool   setYMD( int y, int m, int d );
Packit Service 50c9f2
Packit Service 50c9f2
    QDate  addDays( int days )		const;
Packit Service 50c9f2
    int	   daysTo( const QDate & )	const;
Packit Service 50c9f2
Packit Service 50c9f2
    bool   operator==( const QDate &d ) const { return jd == d.jd; }
Packit Service 50c9f2
    bool   operator!=( const QDate &d ) const { return jd != d.jd; }
Packit Service 50c9f2
    bool   operator<( const QDate &d )	const { return jd < d.jd; }
Packit Service 50c9f2
    bool   operator<=( const QDate &d ) const { return jd <= d.jd; }
Packit Service 50c9f2
    bool   operator>( const QDate &d )	const { return jd > d.jd; }
Packit Service 50c9f2
    bool   operator>=( const QDate &d ) const { return jd >= d.jd; }
Packit Service 50c9f2
Packit Service 50c9f2
    static QDate currentDate();
Packit Service 50c9f2
    static bool	 isValid( int y, int m, int d );
Packit Service 50c9f2
    static bool	 leapYear( int year );
Packit Service 50c9f2
Packit Service 50c9f2
protected:
Packit Service 50c9f2
    static uint	 greg2jul( int y, int m, int d );
Packit Service 50c9f2
    static void	 jul2greg( uint jd, int &y, int &m, int &d );
Packit Service 50c9f2
private:
Packit Service 50c9f2
    static const char * const monthNames[];
Packit Service 50c9f2
    static const char * const weekdayNames[];
Packit Service 50c9f2
    uint	 jd;
Packit Service 50c9f2
    friend class QDateTime;
Packit Service 50c9f2
#ifndef QT_NO_DATASTREAM
Packit Service 50c9f2
    friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QDate & );
Packit Service 50c9f2
    friend Q_EXPORT QDataStream &operator>>( QDataStream &, QDate & );
Packit Service 50c9f2
#endif
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
/*****************************************************************************
Packit Service 50c9f2
  QTime class
Packit Service 50c9f2
 *****************************************************************************/
Packit Service 50c9f2
Packit Service 50c9f2
class Q_EXPORT QTime
Packit Service 50c9f2
{
Packit Service 50c9f2
public:
Packit Service 50c9f2
    QTime() { ds=0; }				// set null time
Packit Service 50c9f2
    QTime( int h, int m, int s=0, int ms=0 );	// set time
Packit Service 50c9f2
Packit Service 50c9f2
    bool   isNull()	 const { return ds == 0; }
Packit Service 50c9f2
    bool   isValid()	 const;			// valid time
Packit Service 50c9f2
Packit Service 50c9f2
    int	   hour()	 const;			// 0..23
Packit Service 50c9f2
    int	   minute()	 const;			// 0..59
Packit Service 50c9f2
    int	   second()	 const;			// 0..59
Packit Service 50c9f2
    int	   msec()	 const;			// 0..999
Packit Service 50c9f2
Packit Service 50c9f2
    QString toString()	 const;
Packit Service 50c9f2
Packit Service 50c9f2
    bool   setHMS( int h, int m, int s, int ms=0 );
Packit Service 50c9f2
Packit Service 50c9f2
    QTime  addSecs( int secs )		const;
Packit Service 50c9f2
    int	   secsTo( const QTime & )	const;
Packit Service 50c9f2
    QTime  addMSecs( int ms )		const;
Packit Service 50c9f2
    int	   msecsTo( const QTime & )	const;
Packit Service 50c9f2
Packit Service 50c9f2
    bool   operator==( const QTime &d ) const { return ds == d.ds; }
Packit Service 50c9f2
    bool   operator!=( const QTime &d ) const { return ds != d.ds; }
Packit Service 50c9f2
    bool   operator<( const QTime &d )	const { return ds < d.ds; }
Packit Service 50c9f2
    bool   operator<=( const QTime &d ) const { return ds <= d.ds; }
Packit Service 50c9f2
    bool   operator>( const QTime &d )	const { return ds > d.ds; }
Packit Service 50c9f2
    bool   operator>=( const QTime &d ) const { return ds >= d.ds; }
Packit Service 50c9f2
Packit Service 50c9f2
    static QTime currentTime();
Packit Service 50c9f2
    static bool	 isValid( int h, int m, int s, int ms=0 );
Packit Service 50c9f2
Packit Service 50c9f2
    void   start();
Packit Service 50c9f2
    int	   restart();
Packit Service 50c9f2
    int	   elapsed();
Packit Service 50c9f2
Packit Service 50c9f2
private:
Packit Service 50c9f2
    static bool currentTime( QTime * );
Packit Service 50c9f2
Packit Service 50c9f2
    uint   ds;
Packit Service 50c9f2
    friend class QDateTime;
Packit Service 50c9f2
#ifndef QT_NO_DATASTREAM
Packit Service 50c9f2
    friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QTime & );
Packit Service 50c9f2
    friend Q_EXPORT QDataStream &operator>>( QDataStream &, QTime & );
Packit Service 50c9f2
#endif
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
/*****************************************************************************
Packit Service 50c9f2
  QDateTime class
Packit Service 50c9f2
 *****************************************************************************/
Packit Service 50c9f2
Packit Service 50c9f2
class Q_EXPORT QDateTime
Packit Service 50c9f2
{
Packit Service 50c9f2
public:
Packit Service 50c9f2
    QDateTime() {}				// set null date and null time
Packit Service 50c9f2
    QDateTime( const QDate & );
Packit Service 50c9f2
    QDateTime( const QDate &, const QTime & );
Packit Service 50c9f2
Packit Service 50c9f2
    bool   isNull()	const		{ return d.isNull() && t.isNull(); }
Packit Service 50c9f2
    bool   isValid()	const		{ return d.isValid() && t.isValid(); }
Packit Service 50c9f2
Packit Service 50c9f2
    QDate  date()	const		{ return d; }
Packit Service 50c9f2
    QTime  time()	const		{ return t; }
Packit Service 50c9f2
    void   setDate( const QDate &date ) { d=date; }
Packit Service 50c9f2
    void   setTime( const QTime &time ) { t=time; }
Packit Service 50c9f2
    void   setTime_t( uint secsSince1Jan1970UTC );
Packit Service 50c9f2
    void   setTimeUtc_t( uint secsSince1Jan1970UTC );
Packit Service 50c9f2
Packit Service 50c9f2
    QString toString()	const;
Packit Service 50c9f2
Packit Service 50c9f2
    QDateTime addDays( int days )	const;
Packit Service 50c9f2
    QDateTime addSecs( int secs )	const;
Packit Service 50c9f2
    int	   daysTo( const QDateTime & )	const;
Packit Service 50c9f2
    int	   secsTo( const QDateTime & )	const;
Packit Service 50c9f2
Packit Service 50c9f2
    bool   operator==( const QDateTime &dt ) const;
Packit Service 50c9f2
    bool   operator!=( const QDateTime &dt ) const;
Packit Service 50c9f2
    bool   operator<( const QDateTime &dt )  const;
Packit Service 50c9f2
    bool   operator<=( const QDateTime &dt ) const;
Packit Service 50c9f2
    bool   operator>( const QDateTime &dt )  const;
Packit Service 50c9f2
    bool   operator>=( const QDateTime &dt ) const;
Packit Service 50c9f2
Packit Service 50c9f2
    static QDateTime currentDateTime();
Packit Service 50c9f2
Packit Service 50c9f2
private:
Packit Service 50c9f2
    QDate  d;
Packit Service 50c9f2
    QTime  t;
Packit Service 50c9f2
#ifndef QT_NO_DATASTREAM
Packit Service 50c9f2
    friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QDateTime &);
Packit Service 50c9f2
    friend Q_EXPORT QDataStream &operator>>( QDataStream &, QDateTime & );
Packit Service 50c9f2
#endif
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
/*****************************************************************************
Packit Service 50c9f2
  Date and time stream functions
Packit Service 50c9f2
 *****************************************************************************/
Packit Service 50c9f2
Packit Service 50c9f2
#ifndef QT_NO_DATASTREAM
Packit Service 50c9f2
Q_EXPORT QDataStream &operator<<( QDataStream &, const QDate & );
Packit Service 50c9f2
Q_EXPORT QDataStream &operator>>( QDataStream &, QDate & );
Packit Service 50c9f2
Q_EXPORT QDataStream &operator<<( QDataStream &, const QTime & );
Packit Service 50c9f2
Q_EXPORT QDataStream &operator>>( QDataStream &, QTime & );
Packit Service 50c9f2
Q_EXPORT QDataStream &operator<<( QDataStream &, const QDateTime & );
Packit Service 50c9f2
Q_EXPORT QDataStream &operator>>( QDataStream &, QDateTime & );
Packit Service 50c9f2
#endif // QT_NO_DATASTREAM
Packit Service 50c9f2
Packit Service 50c9f2
#endif // QDATETIME_H