]> git.saurik.com Git - wxWidgets.git/blob - include/wx/time.h
Added WXHTREEITEM
[wxWidgets.git] / include / wx / time.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: time.h
3 // Purpose: wxTime class, from NIHCL
4 // Author: Julian Smart, after K. E. Gorlen
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TIMEH__
13 #define _WX_TIMEH__
14
15 #include "wx/object.h"
16
17 #if wxUSE_TIMEDATE
18
19 #ifdef __GNUG__
20 #pragma interface "time.h"
21 #endif
22
23 class WXDLLEXPORT wxDate;
24
25 typedef unsigned short hourTy;
26 typedef unsigned short minuteTy;
27 typedef unsigned short secondTy;
28 typedef unsigned long clockTy;
29
30 class WXDLLEXPORT wxTime: public wxObject
31 {
32 DECLARE_DYNAMIC_CLASS(wxTime)
33
34 public: // type definitions
35 enum tFormat { wx12h, wx24h };
36 enum tPrecision { wxStdMinSec, wxStdMin };
37 private:
38 static tFormat Format;
39 static tPrecision Precision;
40
41 clockTy sec; /* seconds since 1/1/1901 */
42
43 bool IsDST() const;
44 wxTime GetLocalTime() const;
45 private: // static member functions
46 static wxTime GetLocalTime(const wxDate& date, hourTy h=0, minuteTy m=0, secondTy s=0);
47 static wxTime GetBeginDST(unsigned year);
48 static wxTime GetEndDST(unsigned year);
49 public:
50 wxTime(); // current time
51 wxTime(clockTy s) { sec = s; }
52 wxTime(const wxTime& t) { (*this) = t ; }
53 wxTime(hourTy h, minuteTy m, secondTy s =0, bool dst =FALSE);
54 wxTime(const wxDate&, hourTy h =0, minuteTy m =0, secondTy s=0, bool dst =FALSE);
55 // Convert to string
56 operator char * (void);
57 operator wxDate() const;
58 bool operator<(const wxTime& t) const { return sec < t.sec; }
59 bool operator<=(const wxTime& t) const { return sec <= t.sec; }
60 bool operator>(const wxTime& t) const { return sec > t.sec; }
61 bool operator>=(const wxTime& t) const { return sec >= t.sec; }
62 bool operator==(const wxTime& t) const { return sec == t.sec; }
63 bool operator!=(const wxTime& t) const { return sec != t.sec; }
64 void operator=(const wxTime& t) { sec = t.sec; }
65 friend wxTime operator+(const wxTime& t, long s) { return wxTime(t.sec+s); }
66 friend wxTime operator+(long s, const wxTime& t) { return wxTime(t.sec+s); }
67 long operator-(const wxTime& t) const { return sec - t.sec; }
68 wxTime operator-(long s) const { return wxTime(sec-s); }
69 void operator+=(long s) { sec += s; }
70 void operator-=(long s) { sec -= s; }
71 bool IsBetween(const wxTime& a, const wxTime& b) const;
72 hourTy GetHour() const; // hour in local time
73 hourTy GetHourGMT() const; // hour in GMT
74 minuteTy GetMinute() const; // minute in local time
75 minuteTy GetMinuteGMT() const; // minute in GMT
76 secondTy GetSecond() const; // second in local time or GMT
77 clockTy GetSeconds() const { return sec; }
78 wxTime Max(const wxTime&) const;
79 wxTime Min(const wxTime&) const;
80 static void SetFormat(const tFormat lFormat = wx12h,
81 const tPrecision lPrecision = wxStdMinSec);
82 char *FormatTime() const;
83 /*
84 virtual int compare(const Object&) const;
85 virtual void deepenShallowCopy(); // {}
86 virtual unsigned hash() const;
87 virtual bool isEqual(const Object&) const;
88 virtual void printOn(ostream& strm =cout) const;
89 virtual const Class* species() const;
90 */
91 };
92
93 #endif
94 // wxUSE_TIMEDATE
95 #endif
96 // _WX_TIMEH__
97