ScummVM API documentation
atltime.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GRAPHICS_MFC_ATLTIME_H
23 #define GRAPHICS_MFC_ATLTIME_H
24 
25 #include "graphics/mfc/minwindef.h"
26 #include "graphics/mfc/afxstr.h"
27 
28 namespace Graphics {
29 namespace MFC {
30 
31 class CTimeSpan {
32 public:
33  CTimeSpan();
34  CTimeSpan(int64 time);
35  CTimeSpan(
36  long lDays,
37  int nHours,
38  int nMins,
39  int nSecs);
40 
41  int64 GetDays() const;
42  int64 GetTotalHours() const;
43  long GetHours() const;
44  int64 GetTotalMinutes() const;
45  long GetMinutes() const;
46  int64 GetTotalSeconds() const;
47  long GetSeconds() const;
48 
49  int64 GetTimeSpan() const;
50 
51  CTimeSpan operator+(CTimeSpan span) const;
52  CTimeSpan operator-(CTimeSpan span) const;
53  CTimeSpan &operator+=(CTimeSpan span);
54  CTimeSpan &operator-=(CTimeSpan span);
55  bool operator==(CTimeSpan span) const;
56  bool operator!=(CTimeSpan span) const;
57  bool operator<(CTimeSpan span) const;
58  bool operator>(CTimeSpan span) const;
59  bool operator<=(CTimeSpan span) const;
60  bool operator>=(CTimeSpan span) const;
61 
62 public:
63  CString Format(const char *pszFormat) const;
64  CString Format(unsigned int nID) const;
65 
66 private:
67  int64 m_timeSpan;
68 };
69 
70 class CTime {
71 public:
72  static CTime WINAPI GetCurrentTime();
73  static bool WINAPI IsValidFILETIME(const FILETIME &ft);
74 
75  CTime();
76  CTime(int64 time);
77  CTime(
78  int nYear,
79  int nMonth,
80  int nDay,
81  int nHour,
82  int nMin,
83  int nSec,
84  int nDST = -1);
85  CTime(
86  uint16 wDosDate,
87  uint16 wDosTime,
88  int nDST = -1);
89  CTime(
90  const SYSTEMTIME &st,
91  int nDST = -1);
92  CTime(
93  const FILETIME &ft,
94  int nDST = -1);
95 
96  CTime &operator=(int64 time);
97 
98  CTime &operator+=(CTimeSpan span);
99  CTime &operator-=(CTimeSpan span);
100 
101  CTimeSpan operator-(CTime time) const;
102  CTime operator-(CTimeSpan span) const;
103  CTime operator+(CTimeSpan span) const;
104 
105  bool operator==(CTime time) const;
106  bool operator!=(CTime time) const;
107  bool operator<(CTime time) const;
108  bool operator>(CTime time) const;
109  bool operator<=(CTime time) const;
110  bool operator>=(CTime time) const;
111 
112  int64 GetTime() const;
113 
114  int GetYear() const;
115  int GetMonth() const;
116  int GetDay() const;
117  int GetHour() const;
118  int GetMinute() const;
119  int GetSecond() const;
120  int GetDayOfWeek() const;
121 
122  // formatting using "C" strftime
123  CString Format(const char *pszFormat) const;
124  CString FormatGmt(const char *pszFormat) const;
125  CString Format(unsigned int nFormatID) const;
126  CString FormatGmt(unsigned int nFormatID) const;
127 
128 private:
129  int64 m_time;
130 };
131 
133 public:
134  CFileTimeSpan();
135  CFileTimeSpan(const CFileTimeSpan &span);
136  CFileTimeSpan(int64 nSpan);
137 
138  CFileTimeSpan &operator=(const CFileTimeSpan &span);
139 
140  CFileTimeSpan &operator+=(CFileTimeSpan span);
141  CFileTimeSpan &operator-=(CFileTimeSpan span);
142 
143  CFileTimeSpan operator+(CFileTimeSpan span) const;
144  CFileTimeSpan operator-(CFileTimeSpan span) const;
145 
146  bool operator==(CFileTimeSpan span) const;
147  bool operator!=(CFileTimeSpan span) const;
148  bool operator<(CFileTimeSpan span) const;
149  bool operator>(CFileTimeSpan span) const;
150  bool operator<=(CFileTimeSpan span) const;
151  bool operator>=(CFileTimeSpan span) const;
152 
153  int64 GetTimeSpan() const;
154  void SetTimeSpan(int64 nSpan);
155 
156 protected:
157  int64 m_nSpan;
158 };
159 
160 class CFileTime : public FILETIME {
161 public:
162  CFileTime();
163  CFileTime(const FILETIME &ft);
164  CFileTime(uint64 nTime);
165 
166  static CFileTime WINAPI GetCurrentTime();
167 
168  CFileTime &operator=(const FILETIME &ft);
169 
170  CFileTime &operator+=(CFileTimeSpan span);
171  CFileTime &operator-=(CFileTimeSpan span);
172 
173  CFileTime operator+(CFileTimeSpan span) const;
174  CFileTime operator-(CFileTimeSpan span) const;
175  CFileTimeSpan operator-(CFileTime ft) const;
176 
177  bool operator==(CFileTime ft) const;
178  bool operator!=(CFileTime ft) const;
179  bool operator<(CFileTime ft) const;
180  bool operator>(CFileTime ft) const;
181  bool operator<=(CFileTime ft) const;
182  bool operator>=(CFileTime ft) const;
183 
184  uint64 GetTime() const;
185  void SetTime(uint64 nTime);
186 
187  CFileTime UTCToLocal() const;
188  CFileTime LocalToUTC() const;
189 
190  static const uint64 Millisecond = 10000;
191  static const uint64 Second = Millisecond * static_cast<uint64>(1000);
192  static const uint64 Minute = Second * static_cast<uint64>(60);
193  static const uint64 Hour = Minute * static_cast<uint64>(60);
194  static const uint64 Day = Hour * static_cast<uint64>(24);
195  static const uint64 Week = Day * static_cast<uint64>(7);
196 };
197 
198 } // namespace MFC
199 } // namespace Graphics
200 
201 #endif
Definition: atltime.h:70
Definition: afxstr.h:31
Definition: atltime.h:31
Definition: formatinfo.h:28
Definition: atltime.h:160
Definition: minwindef.h:228
Definition: atltime.h:132
Definition: minwindef.h:223