ReactOS 0.4.16-dev-320-g3bd9ddc
ATL::CTime Class Reference

#include <atltime.h>

Public Member Functions

 CTime () noexcept
 
 CTime (__time64_t time) noexcept
 
 CTime (int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, int nDST=-1)
 
 CTime (WORD wDosDate, WORD wDosTime, int nDST=-1)
 
 CTime (const SYSTEMTIME &st, int nDST=-1) noexcept
 
 CTime (const FILETIME &ft, int nDST=-1)
 
 CTime (const DBTIMESTAMP &dbts, int nDST=-1) noexcept
 
CString Format (LPCTSTR pszFormat) const
 
CString Format (UINT nFormatID) const
 
CString FormatGmt (LPCTSTR pszFormat) const
 
CString FormatGmt (UINT nFormatID) const
 
bool GetAsDBTIMESTAMP (DBTIMESTAMP &dbts) const noexcept
 
bool GetAsSystemTime (SYSTEMTIME &st) const noexcept
 
int GetDay () const noexcept
 
int GetDayOfWeek () const noexcept
 
struct tmGetGmtTm (struct tm *ptm) const
 
int GetHour () const noexcept
 
struct tmGetLocalTm (struct tm *ptm) const
 
int GetMinute () const noexcept
 
int GetMonth () const noexcept
 
int GetSecond () const noexcept
 
__time64_t GetTime () const noexcept
 
int GetYear ()
 
CTime operator+ (CTimeSpan timeSpan) const noexcept
 
CTime operator- (CTimeSpan timeSpan) const noexcept
 
CTimeSpan operator- (CTime time) const noexcept
 
CTimeoperator+= (CTimeSpan span) noexcept
 
CTimeoperator-= (CTimeSpan span) noexcept
 
CTimeoperator= (__time64_t time) noexcept
 
bool operator== (CTime time) const noexcept
 
bool operator!= (CTime time) const noexcept
 
bool operator< (CTime time) const noexcept
 
bool operator> (CTime time) const noexcept
 
bool operator<= (CTime time) const noexcept
 
bool operator>= (CTime time) const noexcept
 

Static Public Member Functions

static CTime WINAPI GetCurrentTime () noexcept
 

Private Attributes

__time64_t m_nTime
 

Detailed Description

Definition at line 129 of file atltime.h.

Constructor & Destructor Documentation

◆ CTime() [1/7]

ATL::CTime::CTime ( )
inlinenoexcept

Definition at line 133 of file atltime.h.

134 {
135 // leave uninitialized
136 }

Referenced by GetCurrentTime(), operator+(), and operator-().

◆ CTime() [2/7]

ATL::CTime::CTime ( __time64_t  time)
inlinenoexcept

Definition at line 138 of file atltime.h.

139 {
140 m_nTime = time;
141 }
__time64_t m_nTime
Definition: atltime.h:131
__u16 time
Definition: mkdosfs.c:8

◆ CTime() [3/7]

ATL::CTime::CTime ( int  nYear,
int  nMonth,
int  nDay,
int  nHour,
int  nMin,
int  nSec,
int  nDST = -1 
)
inline

Definition at line 143 of file atltime.h.

144 {
145 struct tm time;
146 time.tm_year = nYear;
147 time.tm_mon = nMonth;
148 time.tm_mday = nDay;
149 time.tm_hour = nHour;
150 time.tm_min = nMin;
151 time.tm_sec = nSec;
152 time.tm_isdst = nDST;
154 }
__time64_t _mktime64(struct tm *ptm)
Definition: mktime.c:148
Definition: time.h:68

◆ CTime() [4/7]

ATL::CTime::CTime ( WORD  wDosDate,
WORD  wDosTime,
int  nDST = -1 
)
inline

Definition at line 156 of file atltime.h.

157 {
158 FILETIME ft;
159 DosDateTimeToFileTime(wDosDate, wDosTime, &ft);
160 SYSTEMTIME st;
161 FileTimeToSystemTime(&ft, &st);
162 struct tm time;
163 time.tm_year = st.wYear;
164 time.tm_mon = st.wMonth;
165 time.tm_wday = st.wDayOfWeek;
166 time.tm_hour = st.wHour;
167 time.tm_min = st.wMinute;
168 time.tm_sec = st.wSecond;
169 time.tm_isdst = nDST;
171 }
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI DosDateTimeToFileTime(IN WORD wFatDate, IN WORD wFatTime, OUT LPFILETIME lpFileTime)
Definition: time.c:75
WORD wYear
Definition: winbase.h:930
WORD wMonth
Definition: winbase.h:931
WORD wHour
Definition: winbase.h:934
WORD wSecond
Definition: winbase.h:936
WORD wMinute
Definition: winbase.h:935
WORD wDayOfWeek
Definition: winbase.h:932

◆ CTime() [5/7]

ATL::CTime::CTime ( const SYSTEMTIME st,
int  nDST = -1 
)
inlinenoexcept

Definition at line 173 of file atltime.h.

174 {
175 struct tm time;
176 time.tm_year = st.wYear;
177 time.tm_mon = st.wMonth;
178 time.tm_wday = st.wDayOfWeek;
179 time.tm_hour = st.wHour;
180 time.tm_min = st.wMinute;
181 time.tm_sec = st.wSecond;
182 time.tm_isdst = nDST;
184 }

◆ CTime() [6/7]

ATL::CTime::CTime ( const FILETIME ft,
int  nDST = -1 
)
inline

Definition at line 186 of file atltime.h.

187 {
188 SYSTEMTIME st;
189 FileTimeToSystemTime(&ft, &st);
190 struct tm time;
191 time.tm_year = st.wYear;
192 time.tm_mon = st.wMonth;
193 time.tm_wday = st.wDayOfWeek;
194 time.tm_hour = st.wHour;
195 time.tm_min = st.wMinute;
196 time.tm_sec = st.wSecond;
197 time.tm_isdst = nDST;
199 }

◆ CTime() [7/7]

ATL::CTime::CTime ( const DBTIMESTAMP dbts,
int  nDST = -1 
)
inlinenoexcept

Definition at line 201 of file atltime.h.

202 {
203 struct tm time;
204 time.tm_year = dbts.year;
205 time.tm_mon = dbts.month;
206 time.tm_hour = dbts.hour;
207 time.tm_min = dbts.minute;
208 time.tm_sec = dbts.second;
209 time.tm_isdst = nDST;
211 }
USHORT month
Definition: oledb.idl:45
SHORT year
Definition: oledb.idl:44
USHORT second
Definition: oledb.idl:49
USHORT hour
Definition: oledb.idl:47
USHORT minute
Definition: oledb.idl:48

Member Function Documentation

◆ Format() [1/2]

CString ATL::CTime::Format ( LPCTSTR  pszFormat) const
inline

Definition at line 213 of file atltime.h.

214 {
215 struct tm time;
216 _localtime64_s(&time, &m_nTime);
217 CString strTime;
218#ifdef UNICODE
219 wcsftime(strTime.GetBuffer(256), 256, pszFormat, &time);
220#else
221 strftime(strTime.GetBuffer(256), 256, pszFormat, &time);
222#endif
223 strTime.ReleaseBuffer();
224 return strTime;
225 }
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:387
size_t CDECL strftime(char *str, size_t max, const char *format, const struct tm *mstm)
Definition: strftime.c:294
size_t CDECL wcsftime(wchar_t *str, size_t max, const wchar_t *format, const struct tm *mstm)
Definition: strftime.c:303

◆ Format() [2/2]

CString ATL::CTime::Format ( UINT  nFormatID) const
inline

Definition at line 227 of file atltime.h.

228 {
229 struct tm time;
230 _localtime64_s(&time, &m_nTime);
231 CString strFormat;
232 strFormat.LoadString(nFormatID);
233 CString strTime;
234#ifdef UNICODE
235 wcsftime(strTime.GetBuffer(256), 256, strFormat, &time);
236#else
237 strftime(strTime.GetBuffer(256), 256, strFormat, &time);
238#endif
239 strTime.ReleaseBuffer();
240 return strTime;
241 }
BOOL LoadString(_In_ UINT nID)
Definition: cstringt.h:639

◆ FormatGmt() [1/2]

CString ATL::CTime::FormatGmt ( LPCTSTR  pszFormat) const
inline

Definition at line 243 of file atltime.h.

244 {
245 struct tm time;
247 CString strTime;
248#ifdef UNICODE
249 wcsftime(strTime.GetBuffer(256), 256, pszFormat, &time);
250#else
251 strftime(strTime.GetBuffer(256), 256, pszFormat, &time);
252#endif
253 strTime.ReleaseBuffer();
254 return strTime;
255 }
errno_t _gmtime64_s(struct tm *ptm, const __time64_t *ptime)
Definition: gmtime.c:122

◆ FormatGmt() [2/2]

CString ATL::CTime::FormatGmt ( UINT  nFormatID) const
inline

Definition at line 257 of file atltime.h.

258 {
259 struct tm time;
261 CString strFormat;
262 strFormat.LoadString(nFormatID);
263 CString strTime;
264#ifdef UNICODE
265 wcsftime(strTime.GetBuffer(256), 256, strFormat, &time);
266#else
267 strftime(strTime.GetBuffer(256), 256, strFormat, &time);
268#endif
269 strTime.ReleaseBuffer();
270 return strTime;
271 }

◆ GetAsDBTIMESTAMP()

bool ATL::CTime::GetAsDBTIMESTAMP ( DBTIMESTAMP dbts) const
inlinenoexcept

Definition at line 273 of file atltime.h.

274 {
275 struct tm time;
277 dbts.year = time.tm_year;
278 dbts.month = time.tm_mon;
279 dbts.day = time.tm_mday;
280 dbts.hour = time.tm_hour;
281 dbts.minute = time.tm_min;
282 dbts.second = time.tm_sec;
283 dbts.fraction = 0;
284 return true; // TODO: error handling?
285 }
ULONG fraction
Definition: oledb.idl:50
USHORT day
Definition: oledb.idl:46

◆ GetAsSystemTime()

bool ATL::CTime::GetAsSystemTime ( SYSTEMTIME st) const
inlinenoexcept

Definition at line 287 of file atltime.h.

288 {
289 struct tm time;
291 st.wYear = time.tm_year;
292 st.wMonth = time.tm_mon;
293 st.wDayOfWeek = time.tm_wday;
294 st.wDay = time.tm_mday;
295 st.wHour = time.tm_hour;
296 st.wMinute = time.tm_min;
297 st.wSecond = time.tm_sec;
298 st.wMilliseconds = 0;
299 return true; // TODO: error handling?
300 }
WORD wMilliseconds
Definition: winbase.h:937
WORD wDay
Definition: winbase.h:933

◆ GetCurrentTime()

static CTime WINAPI ATL::CTime::GetCurrentTime ( )
inlinestaticnoexcept

Definition at line 302 of file atltime.h.

303 {
304 __time64_t time;
305 _time64(&time);
306 return CTime(time);
307 }
CTime() noexcept
Definition: atltime.h:133

◆ GetDay()

int ATL::CTime::GetDay ( ) const
inlinenoexcept

Definition at line 309 of file atltime.h.

310 {
311 struct tm time;
312 _localtime64_s(&time, &m_nTime);
313 return time.tm_mday;
314 }

◆ GetDayOfWeek()

int ATL::CTime::GetDayOfWeek ( ) const
inlinenoexcept

Definition at line 316 of file atltime.h.

317 {
318 struct tm time;
319 _localtime64_s(&time, &m_nTime);
320 return time.tm_wday;
321 }

◆ GetGmtTm()

struct tm * ATL::CTime::GetGmtTm ( struct tm ptm) const
inline

Definition at line 323 of file atltime.h.

324 {
325 _gmtime64_s(ptm, &m_nTime);
326 return ptm;
327 }

◆ GetHour()

int ATL::CTime::GetHour ( ) const
inlinenoexcept

Definition at line 329 of file atltime.h.

330 {
331 struct tm time;
332 _localtime64_s(&time, &m_nTime);
333 return time.tm_hour;
334 }

◆ GetLocalTm()

struct tm * ATL::CTime::GetLocalTm ( struct tm ptm) const
inline

Definition at line 336 of file atltime.h.

337 {
338 _localtime64_s(ptm, &m_nTime);
339 return ptm;
340 }

◆ GetMinute()

int ATL::CTime::GetMinute ( ) const
inlinenoexcept

Definition at line 342 of file atltime.h.

343 {
344 struct tm time;
345 _localtime64_s(&time, &m_nTime);
346 return time.tm_min;
347 }

◆ GetMonth()

int ATL::CTime::GetMonth ( ) const
inlinenoexcept

Definition at line 349 of file atltime.h.

350 {
351 struct tm time;
352 _localtime64_s(&time, &m_nTime);
353 return time.tm_mon;
354 }

◆ GetSecond()

int ATL::CTime::GetSecond ( ) const
inlinenoexcept

Definition at line 356 of file atltime.h.

357 {
358 struct tm time;
359 _localtime64_s(&time, &m_nTime);
360 return time.tm_sec;
361 }

◆ GetTime()

__time64_t ATL::CTime::GetTime ( ) const
inlinenoexcept

Definition at line 363 of file atltime.h.

364 {
365 return m_nTime;
366 }

◆ GetYear()

int ATL::CTime::GetYear ( )
inline

Definition at line 368 of file atltime.h.

369 {
370 struct tm time;
371 _localtime64_s(&time, &m_nTime);
372 return time.tm_year;
373 }

◆ operator!=()

bool ATL::CTime::operator!= ( CTime  time) const
inlinenoexcept

Definition at line 418 of file atltime.h.

419 {
420 return m_nTime != time.GetTime();
421 }

◆ operator+()

CTime ATL::CTime::operator+ ( CTimeSpan  timeSpan) const
inlinenoexcept

Definition at line 380 of file atltime.h.

381 {
382 return CTime(m_nTime + timeSpan.GetTimeSpan());
383 }
__time64_t GetTimeSpan() const noexcept
Definition: atltime.h:117

◆ operator+=()

CTime & ATL::CTime::operator+= ( CTimeSpan  span)
inlinenoexcept

Definition at line 395 of file atltime.h.

396 {
397 m_nTime += span.GetTimeSpan();
398 return *this;
399 }
GLenum GLenum GLvoid GLvoid GLvoid * span
Definition: glext.h:5664

◆ operator-() [1/2]

CTimeSpan ATL::CTime::operator- ( CTime  time) const
inlinenoexcept

Definition at line 390 of file atltime.h.

391 {
392 return CTimeSpan(m_nTime - time.GetTime());
393 }

◆ operator-() [2/2]

CTime ATL::CTime::operator- ( CTimeSpan  timeSpan) const
inlinenoexcept

Definition at line 385 of file atltime.h.

386 {
387 return CTime(m_nTime - timeSpan.GetTimeSpan());
388 }

◆ operator-=()

CTime & ATL::CTime::operator-= ( CTimeSpan  span)
inlinenoexcept

Definition at line 401 of file atltime.h.

402 {
403 m_nTime -= span.GetTimeSpan();
404 return *this;
405 }

◆ operator<()

bool ATL::CTime::operator< ( CTime  time) const
inlinenoexcept

Definition at line 423 of file atltime.h.

424 {
425 return m_nTime < time.GetTime();
426 }

◆ operator<=()

bool ATL::CTime::operator<= ( CTime  time) const
inlinenoexcept

Definition at line 433 of file atltime.h.

434 {
435 return m_nTime <= time.GetTime();
436 }

◆ operator=()

CTime & ATL::CTime::operator= ( __time64_t  time)
inlinenoexcept

Definition at line 407 of file atltime.h.

408 {
409 m_nTime = time;
410 return *this;
411 }

◆ operator==()

bool ATL::CTime::operator== ( CTime  time) const
inlinenoexcept

Definition at line 413 of file atltime.h.

414 {
415 return m_nTime == time.GetTime();
416 }

◆ operator>()

bool ATL::CTime::operator> ( CTime  time) const
inlinenoexcept

Definition at line 428 of file atltime.h.

429 {
430 return m_nTime > time.GetTime();
431 }

◆ operator>=()

bool ATL::CTime::operator>= ( CTime  time) const
inlinenoexcept

Definition at line 438 of file atltime.h.

439 {
440 return m_nTime >= time.GetTime();
441 }

Member Data Documentation

◆ m_nTime


The documentation for this class was generated from the following file: