]> git.saurik.com Git - wxWidgets.git/blame - include/wx/time.h
Made listctrl header BG grey again
[wxWidgets.git] / include / wx / time.h
CommitLineData
c801d85f
KB
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
e8b6d59d 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_TIMEH__
13#define _WX_TIMEH__
c801d85f
KB
14
15#include "wx/object.h"
16
9838df2c 17#if wxUSE_TIMEDATE
c801d85f
KB
18
19#ifdef __GNUG__
20#pragma interface "time.h"
21#endif
22
23class WXDLLEXPORT wxDate;
24
25typedef unsigned short hourTy;
26typedef unsigned short minuteTy;
27typedef unsigned short secondTy;
28typedef unsigned long clockTy;
29
30class WXDLLEXPORT wxTime: public wxObject
31{
32 DECLARE_DYNAMIC_CLASS(wxTime)
33
34public: // type definitions
e8b6d59d
JS
35 enum tFormat { wx12h, wx24h };
36 enum tPrecision { wxStdMinSec, wxStdMin };
c801d85f 37private:
e8b6d59d
JS
38 static tFormat Format;
39 static tPrecision Precision;
c801d85f 40
e8b6d59d 41 clockTy sec; /* seconds since 1/1/1901 */
c801d85f 42
e8b6d59d
JS
43 bool IsDST() const;
44 wxTime GetLocalTime() const;
45private: // 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);
c801d85f 49public:
e8b6d59d
JS
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);
56
57 // Convert to string
ce3ed50d 58#ifndef __SALFORDC__
6d9bd068 59 operator wxChar * (void);
e8b6d59d 60 operator wxDate() const;
ce3ed50d
JS
61#endif
62
e8b6d59d
JS
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 bool operator>=(const wxTime& t) const { return sec >= t.sec; }
67 bool operator==(const wxTime& t) const { return sec == t.sec; }
68 bool operator!=(const wxTime& t) const { return sec != t.sec; }
69 friend wxTime operator+(const wxTime& t, long s) { return wxTime(t.sec+s); }
70 friend wxTime operator+(long s, const wxTime& t) { return wxTime(t.sec+s); }
71 long operator-(const wxTime& t) const { return sec - t.sec; }
72 wxTime operator-(long s) const { return wxTime(sec-s); }
73 void operator+=(long s) { sec += s; }
74 void operator-=(long s) { sec -= s; }
75 bool IsBetween(const wxTime& a, const wxTime& b) const;
76
77 /// Get day
78 int GetDay() const;
79 /// Get month
80 int GetMonth() const;
81 /// Get year
82 int GetYear() const;
83 /// Get day of week (0=Sunday 6=Saturday)
84 int GetDayOfWeek() const;
85
86 hourTy GetHour() const; // hour in local time
87 hourTy GetHourGMT() const; // hour in GMT
88 minuteTy GetMinute() const; // minute in local time
89 minuteTy GetMinuteGMT() const; // minute in GMT
90 secondTy GetSecond() const; // second in local time or GMT
91 clockTy GetSeconds() const { return sec; }
92 secondTy GetSecondGMT() const ;
93 wxTime Max(const wxTime&) const;
94 wxTime Min(const wxTime&) const;
95 static void SetFormat(const tFormat lFormat = wx12h,
96 const tPrecision lPrecision = wxStdMinSec);
6d9bd068 97 wxChar *FormatTime() const;
c801d85f 98/*
e8b6d59d
JS
99 virtual int compare(const Object&) const;
100 virtual void deepenShallowCopy(); // {}
101 virtual unsigned hash() const;
102 virtual bool isEqual(const Object&) const;
103 virtual void printOn(ostream& strm =cout) const;
104 virtual const Class* species() const;
c801d85f
KB
105*/
106};
107
108#endif
47d67540 109 // wxUSE_TIMEDATE
c801d85f 110#endif
34138703 111 // _WX_TIMEH__
c801d85f 112