1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: time.h
|
|
|
|
// Purpose: wxTime class, from NIHCL
|
|
|
|
// Author: Julian Smart, after K. E. Gorlen
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart and Markus Holzem
|
1998-12-08 13:54:05 -05:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_TIMEH__
|
|
|
|
#define _WX_TIMEH__
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
#include "wx/object.h"
|
|
|
|
|
1999-01-24 09:57:09 -05:00
|
|
|
#if wxUSE_TIMEDATE
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "time.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxDate;
|
|
|
|
|
|
|
|
typedef unsigned short hourTy;
|
|
|
|
typedef unsigned short minuteTy;
|
|
|
|
typedef unsigned short secondTy;
|
|
|
|
typedef unsigned long clockTy;
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxTime: public wxObject
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxTime)
|
|
|
|
|
|
|
|
public: // type definitions
|
1998-12-08 13:54:05 -05:00
|
|
|
enum tFormat { wx12h, wx24h };
|
|
|
|
enum tPrecision { wxStdMinSec, wxStdMin };
|
1998-05-20 10:01:55 -04:00
|
|
|
private:
|
1998-12-08 13:54:05 -05:00
|
|
|
static tFormat Format;
|
|
|
|
static tPrecision Precision;
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1998-12-08 13:54:05 -05:00
|
|
|
clockTy sec; /* seconds since 1/1/1901 */
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1998-12-08 13:54:05 -05:00
|
|
|
bool IsDST() const;
|
|
|
|
wxTime GetLocalTime() const;
|
|
|
|
private: // static member functions
|
|
|
|
static wxTime GetLocalTime(const wxDate& date, hourTy h=0, minuteTy m=0, secondTy s=0);
|
|
|
|
static wxTime GetBeginDST(unsigned year);
|
|
|
|
static wxTime GetEndDST(unsigned year);
|
1998-05-20 10:01:55 -04:00
|
|
|
public:
|
1998-12-08 13:54:05 -05:00
|
|
|
wxTime(); // current time
|
|
|
|
wxTime(clockTy s) { sec = s; }
|
|
|
|
void operator=(const wxTime& t) { sec = t.sec; } // Ordering required for some compilers
|
|
|
|
wxTime(const wxTime& t) { (*this) = t ; }
|
|
|
|
wxTime(hourTy h, minuteTy m, secondTy s =0, bool dst =FALSE);
|
|
|
|
wxTime(const wxDate&, hourTy h =0, minuteTy m =0, secondTy s=0, bool dst =FALSE);
|
|
|
|
|
|
|
|
// Convert to string
|
1999-01-19 06:00:22 -05:00
|
|
|
#ifndef __SALFORDC__
|
1999-04-13 06:31:53 -04:00
|
|
|
operator wxChar * (void);
|
1998-12-08 13:54:05 -05:00
|
|
|
operator wxDate() const;
|
1999-01-19 06:00:22 -05:00
|
|
|
#endif
|
|
|
|
|
1998-12-08 13:54:05 -05:00
|
|
|
bool operator<(const wxTime& t) const { return sec < t.sec; }
|
|
|
|
bool operator<=(const wxTime& t) const { return sec <= t.sec; }
|
|
|
|
bool operator>(const wxTime& t) const { return sec > t.sec; }
|
|
|
|
bool operator>=(const wxTime& t) const { return sec >= t.sec; }
|
|
|
|
bool operator==(const wxTime& t) const { return sec == t.sec; }
|
|
|
|
bool operator!=(const wxTime& t) const { return sec != t.sec; }
|
|
|
|
friend wxTime operator+(const wxTime& t, long s) { return wxTime(t.sec+s); }
|
|
|
|
friend wxTime operator+(long s, const wxTime& t) { return wxTime(t.sec+s); }
|
|
|
|
long operator-(const wxTime& t) const { return sec - t.sec; }
|
|
|
|
wxTime operator-(long s) const { return wxTime(sec-s); }
|
|
|
|
void operator+=(long s) { sec += s; }
|
|
|
|
void operator-=(long s) { sec -= s; }
|
|
|
|
bool IsBetween(const wxTime& a, const wxTime& b) const;
|
|
|
|
|
|
|
|
/// Get day
|
|
|
|
int GetDay() const;
|
|
|
|
/// Get month
|
|
|
|
int GetMonth() const;
|
|
|
|
/// Get year
|
|
|
|
int GetYear() const;
|
|
|
|
/// Get day of week (0=Sunday 6=Saturday)
|
|
|
|
int GetDayOfWeek() const;
|
|
|
|
|
|
|
|
hourTy GetHour() const; // hour in local time
|
|
|
|
hourTy GetHourGMT() const; // hour in GMT
|
|
|
|
minuteTy GetMinute() const; // minute in local time
|
|
|
|
minuteTy GetMinuteGMT() const; // minute in GMT
|
|
|
|
secondTy GetSecond() const; // second in local time or GMT
|
|
|
|
clockTy GetSeconds() const { return sec; }
|
|
|
|
secondTy GetSecondGMT() const ;
|
|
|
|
wxTime Max(const wxTime&) const;
|
|
|
|
wxTime Min(const wxTime&) const;
|
|
|
|
static void SetFormat(const tFormat lFormat = wx12h,
|
|
|
|
const tPrecision lPrecision = wxStdMinSec);
|
1999-04-13 06:31:53 -04:00
|
|
|
wxChar *FormatTime() const;
|
1998-05-20 10:01:55 -04:00
|
|
|
/*
|
1998-12-08 13:54:05 -05:00
|
|
|
virtual int compare(const Object&) const;
|
|
|
|
virtual void deepenShallowCopy(); // {}
|
|
|
|
virtual unsigned hash() const;
|
|
|
|
virtual bool isEqual(const Object&) const;
|
|
|
|
virtual void printOn(ostream& strm =cout) const;
|
|
|
|
virtual const Class* species() const;
|
1998-05-20 10:01:55 -04:00
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-09-25 09:28:52 -04:00
|
|
|
// wxUSE_TIMEDATE
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
1998-08-14 20:23:28 -04:00
|
|
|
// _WX_TIMEH__
|
1998-05-20 10:01:55 -04:00
|
|
|
|