]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/time.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTime class, from NIHCL
4 // Author: Julian Smart, after K. E. Gorlen
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/object.h"
20 #pragma interface "time.h"
23 class WXDLLEXPORT wxDate
;
25 typedef unsigned short hourTy
;
26 typedef unsigned short minuteTy
;
27 typedef unsigned short secondTy
;
28 typedef unsigned long clockTy
;
30 class WXDLLEXPORT wxTime
: public wxObject
32 DECLARE_DYNAMIC_CLASS(wxTime
)
34 public: // type definitions
35 enum tFormat
{ wx12h
, wx24h
};
36 enum tPrecision
{ wxStdMinSec
, wxStdMin
};
38 static tFormat Format
;
39 static tPrecision Precision
;
41 clockTy sec
; /* seconds since 1/1/1901 */
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
);
50 wxTime(); // current time
51 wxTime(clockTy s
) { sec
= s
; }
52 void operator=(const wxTime
& t
) { sec
= t
.sec
; } // Ordering required for some compilers
53 wxTime(const wxTime
& t
) { (*this) = t
; }
54 wxTime(hourTy h
, minuteTy m
, secondTy s
=0, bool dst
=FALSE
);
55 wxTime(const wxDate
&, hourTy h
=0, minuteTy m
=0, secondTy s
=0, bool dst
=FALSE
);
58 operator char * (void);
59 operator wxDate() const;
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 bool operator==(const wxTime
& t
) const { return sec
== t
.sec
; }
65 bool operator!=(const wxTime
& t
) const { return sec
!= t
.sec
; }
66 friend wxTime
operator+(const wxTime
& t
, long s
) { return wxTime(t
.sec
+s
); }
67 friend wxTime
operator+(long s
, const wxTime
& t
) { return wxTime(t
.sec
+s
); }
68 long operator-(const wxTime
& t
) const { return sec
- t
.sec
; }
69 wxTime
operator-(long s
) const { return wxTime(sec
-s
); }
70 void operator+=(long s
) { sec
+= s
; }
71 void operator-=(long s
) { sec
-= s
; }
72 bool IsBetween(const wxTime
& a
, const wxTime
& b
) const;
80 /// Get day of week (0=Sunday 6=Saturday)
81 int GetDayOfWeek() const;
83 hourTy
GetHour() const; // hour in local time
84 hourTy
GetHourGMT() const; // hour in GMT
85 minuteTy
GetMinute() const; // minute in local time
86 minuteTy
GetMinuteGMT() const; // minute in GMT
87 secondTy
GetSecond() const; // second in local time or GMT
88 clockTy
GetSeconds() const { return sec
; }
89 secondTy
GetSecondGMT() const ;
90 wxTime
Max(const wxTime
&) const;
91 wxTime
Min(const wxTime
&) const;
92 static void SetFormat(const tFormat lFormat
= wx12h
,
93 const tPrecision lPrecision
= wxStdMinSec
);
94 char *FormatTime() const;
96 virtual int compare(const Object&) const;
97 virtual void deepenShallowCopy(); // {}
98 virtual unsigned hash() const;
99 virtual bool isEqual(const Object&) const;
100 virtual void printOn(ostream& strm =cout) const;
101 virtual const Class* species() const;