ReactOS 0.4.15-dev-7924-g5949c20
ATL::CTimeSpan Class Reference

#include <atltime.h>

Public Member Functions

 CTimeSpan () noexcept
 
 CTimeSpan (__time64_t time) noexcept
 
 CTimeSpan (LONG lDays, int nHours, int nMins, int nSecs) noexcept
 
CString Format (LPCSTR pFormat) const
 
CString Format (LPCTSTR pszFormat) const
 
CString Format (UINT nID) const
 
LONGLONG GetTotalHours () const noexcept
 
LONGLONG GetTotalMinutes () const noexcept
 
LONGLONG GetTotalSeconds () const noexcept
 
LONGLONG GetDays () const noexcept
 
LONG GetHours () const noexcept
 
LONG GetMinutes () const noexcept
 
LONG GetSeconds () const noexcept
 
__time64_t GetTimeSpan () const noexcept
 

Private Attributes

__time64_t m_nSpan
 

Detailed Description

Definition at line 22 of file atltime.h.

Constructor & Destructor Documentation

◆ CTimeSpan() [1/3]

ATL::CTimeSpan::CTimeSpan ( )
inlinenoexcept

Definition at line 26 of file atltime.h.

27 {
28 // leave uninitialized
29 }

◆ CTimeSpan() [2/3]

ATL::CTimeSpan::CTimeSpan ( __time64_t  time)
inlinenoexcept

Definition at line 31 of file atltime.h.

32 {
33 m_nSpan = time;
34 }
__time64_t m_nSpan
Definition: atltime.h:24
__u16 time
Definition: mkdosfs.c:8

◆ CTimeSpan() [3/3]

ATL::CTimeSpan::CTimeSpan ( LONG  lDays,
int  nHours,
int  nMins,
int  nSecs 
)
inlinenoexcept

Definition at line 36 of file atltime.h.

37 {
38 ATLASSERT(lDays >= 0 && nHours >= 0 && nHours <= 23 && nMins >= 0 && nMins <= 59 && nSecs >= 0 && nSecs <= 59);
39 m_nSpan = ((((LONGLONG)lDays) * 24 + nHours) * 60 + nMins) * 60 + nSecs;
40 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
int64_t LONGLONG
Definition: typedefs.h:68

Member Function Documentation

◆ Format() [1/3]

CString ATL::CTimeSpan::Format ( LPCSTR  pFormat) const
inline

Definition at line 42 of file atltime.h.

43 {
44 struct tm time;
45 _localtime64_s(&time, &m_nSpan);
46 CStringA strTime;
47 strftime(strTime.GetBuffer(256), 256, pFormat, &time);
48 strTime.ReleaseBuffer();
49 return CString(strTime);
50 }
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:387
CStringA CString
Definition: atlstr.h:139
size_t CDECL strftime(char *str, size_t max, const char *format, const struct tm *mstm)
Definition: strftime.c:293
Definition: time.h:68

◆ Format() [2/3]

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

Definition at line 52 of file atltime.h.

53 {
54 struct tm time;
55 _localtime64_s(&time, &m_nSpan);
56 CString strTime;
57#ifdef UNICODE
58 wcsftime(strTime.GetBuffer(256), 256, pszFormat, &time);
59#else
60 strftime(strTime.GetBuffer(256), 256, pszFormat, &time);
61#endif
62 strTime.ReleaseBuffer();
63 return strTime;
64 }
size_t CDECL wcsftime(wchar_t *str, size_t max, const wchar_t *format, const struct tm *mstm)
Definition: strftime.c:302

◆ Format() [3/3]

CString ATL::CTimeSpan::Format ( UINT  nID) const
inline

Definition at line 66 of file atltime.h.

67 {
68 struct tm time;
69 _localtime64_s(&time, &m_nSpan);
70 CString strFormat;
71 strFormat.LoadString(nID);
72 CString strTime;
73#ifdef UNICODE
74 wcsftime(strTime.GetBuffer(256), 256, strFormat, &time);
75#else
76 strftime(strTime.GetBuffer(256), 256, strFormat, &time);
77#endif
78 strTime.ReleaseBuffer();
79 return strTime;
80 }
BOOL LoadString(_In_ UINT nID)
Definition: cstringt.h:639

◆ GetDays()

LONGLONG ATL::CTimeSpan::GetDays ( ) const
inlinenoexcept

Definition at line 97 of file atltime.h.

98 {
99 return m_nSpan / 60 / 60 / 24;
100 }

Referenced by GetHours().

◆ GetHours()

LONG ATL::CTimeSpan::GetHours ( ) const
inlinenoexcept

Definition at line 102 of file atltime.h.

103 {
104 return GetTotalHours() - GetDays() * 24;
105 }
LONGLONG GetDays() const noexcept
Definition: atltime.h:97
LONGLONG GetTotalHours() const noexcept
Definition: atltime.h:82

◆ GetMinutes()

LONG ATL::CTimeSpan::GetMinutes ( ) const
inlinenoexcept

Definition at line 107 of file atltime.h.

108 {
109 return GetTotalMinutes() - GetTotalHours() * 60;
110 }
LONGLONG GetTotalMinutes() const noexcept
Definition: atltime.h:87

◆ GetSeconds()

LONG ATL::CTimeSpan::GetSeconds ( ) const
inlinenoexcept

Definition at line 112 of file atltime.h.

113 {
114 return GetTotalSeconds() - GetTotalMinutes() * 60;
115 }
LONGLONG GetTotalSeconds() const noexcept
Definition: atltime.h:92

◆ GetTimeSpan()

__time64_t ATL::CTimeSpan::GetTimeSpan ( ) const
inlinenoexcept

Definition at line 117 of file atltime.h.

118 {
119 return m_nSpan;
120 }

◆ GetTotalHours()

LONGLONG ATL::CTimeSpan::GetTotalHours ( ) const
inlinenoexcept

Definition at line 82 of file atltime.h.

83 {
84 return m_nSpan / 60 / 60;
85 }

Referenced by GetHours(), and GetMinutes().

◆ GetTotalMinutes()

LONGLONG ATL::CTimeSpan::GetTotalMinutes ( ) const
inlinenoexcept

Definition at line 87 of file atltime.h.

88 {
89 return m_nSpan / 60;
90 }

Referenced by GetMinutes(), and GetSeconds().

◆ GetTotalSeconds()

LONGLONG ATL::CTimeSpan::GetTotalSeconds ( ) const
inlinenoexcept

Definition at line 92 of file atltime.h.

93 {
94 return m_nSpan;
95 }

Referenced by GetSeconds().

Member Data Documentation

◆ m_nSpan

__time64_t ATL::CTimeSpan::m_nSpan
private

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