使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 4905e2e7537d507f218e8e9595485e09d9f3a2b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
//////////////////////////////////////////////////////////////////////
//
// HighTime.h: interface for the CHighTime class.
//
//////////////////////////////////////////////////////////////////////
//
// CHighTime and CHighTimeSpan are two classes for high resolution time
// The range is +/-29000 years and smallest step is 0.1 microsecond
// They works like COleDateTime and COleDateTimeSpan.
// I wrote these because MS could not write working time classes
//
// Author: Hakan Trygg, h.kan@home.se
// Classes are not to be sold for profit.
// Please send me a mail if you find it useful and using it
 
// Revision history: 
// 1.0 : 12 Jan 2000 : /HT : Created
// 1.1 : 19 Jan 2000 : /HT : Made it possible to use classes without MFC
//////////////////////////////////////////////////////////////////////
 
#if !defined(_HIGHTIME_H_)
#define _HIGHTIME_H_
 
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
 
#ifdef _AFXDLL
#define USE_MFC
#endif
 
#ifdef __AFX_H__
#define USE_MFC
#endif
 
#ifndef USE_MFC
#include <time.h>
#include <assert.h>
 
#ifndef ASSERT
    #ifdef _DEBUG
    #define ASSERT assert
    #else
    #define ASSERT
    #endif // _DEBUG
#endif // !ASSERT
 
#endif //!USE_MFC
 
#define HIGH_DATETIME_ERROR (-1)
#define INVALID_DATETIME _T("Invalid datetime")
#define INVALID_SPANTIME _T("Invalid datetimespan")
 
class CHighTime;
class CHighTimeSpan;
 
class AFX_EXT_CLASS CHighTime
{
public:
    static const CHighTime GetPresentTime(bool bLocal=true);
public:
    enum HighTimeStatus {
       valid = 0,
       invalid = 1,
       null = 2,
    };
    CHighTime();
#ifdef OLEDBDECLSPEC
    CHighTime(const DBTIMESTAMP &dateSrc);
#endif
    CHighTime(const CHighTime &dateSrc);
    CHighTime(const LARGE_INTEGER dateSrc);
    CHighTime(const LONGLONG dateSrc);
#if defined(USE_MFC)
    CHighTime(const COleDateTime &dateSrc);
    CHighTime(const CTime &dateSrc);
#endif
    CHighTime(const SYSTEMTIME &systimeSrc);
    CHighTime(const FILETIME &filetimeSrc);
//    CHighTime(const time_t timeSrc);
    CHighTime(int nYear, int nMonth, int nDay,
              int nHour, int nMinute, int nSecond, 
              int nMilli = 0, int nMicro = 0, int nNano = 0);
 
// operators
public:
#ifdef OLEDBDECLSPEC
    const CHighTime& operator=(const DBTIMESTAMP &dateSrc);
#endif
    const CHighTime& operator=(const CHighTime& dateSrc);
    const CHighTime& operator=(const LARGE_INTEGER dateSrc);
    const CHighTime& operator=(const LONGLONG dateSrc);
#if defined(USE_MFC)
    const CHighTime& operator=(const COleDateTime& dateSrc);
    const CHighTime& operator=(const CTime& dateSrc);
#endif
 
    const CHighTime& operator=(const SYSTEMTIME& systimeSrc);
    const CHighTime& operator=(const FILETIME& filetimeSrc);
//    const CHighTime& operator=(const time_t& timeSrc);
    const CHighTime& operator=(const DATE& date);
 
    bool operator==(const CHighTime& date) const;
    bool operator!=(const CHighTime& date) const;
    bool operator<(const CHighTime& date) const;
    bool operator>(const CHighTime& date) const;
    bool operator<=(const CHighTime& date) const;
    bool operator>=(const CHighTime& date) const;
 
    // CHighTime math
    CHighTime operator+(const CHighTimeSpan &dateSpan) const;
    CHighTime operator-(const CHighTimeSpan &dateSpan) const;
    const CHighTime& operator+=(const CHighTimeSpan dateSpan);
    const CHighTime& operator-=(const CHighTimeSpan dateSpan);
 
    // CHighTimeSpan math
    CHighTimeSpan operator-(const CHighTime& date) const;
 
    operator SYSTEMTIME() const;
#ifdef OLEDBDECLSPEC
    operator DBTIMESTAMP() const;
#endif
    operator DATE() const;
    operator FILETIME() const;
    operator LARGE_INTEGER() const {return m_liTime;}
 
    operator LONGLONG() const {return m_liTime.QuadPart;}
#if defined(USE_MFC)
    operator COleDateTime() const;
    operator CTime() const;
    const COleDateTime GetCOleDateTime(bool bAdjusted=false) const;
#endif //defined(USE_MFC)
 
    // Operations
public:
    int SetDateTime(int nYear, int nMonth, int nDay,
                    int nHour, int nMinute, int nSecond, 
                    int nMilli = 0, int nMicro = 0, int nNano = 0);
    int SetDate(int nYear, int nMonth, int nDay);
    int SetTime(int nHour, int nMin, int nSec);
    int SetFracTime(int nMilli, int nMicro, int nNano);
 
    HighTimeStatus GetStatus() const {return m_status;}
    void SetStatus(HighTimeStatus status) { m_status = status; }
    BOOL GetAsSystemTime(SYSTEMTIME& sysTime) const;
 
    int GetYear() const;
    int GetMonth() const;       // month of year (1 = Jan)
    int GetDay() const;         // day of month (0-31)
    int GetHour() const;        // hour in day (0-23)
    int GetMinute() const;      // minute in hour (0-59)
    int GetSecond() const;      // second in minute (0-59)
    int GetMilliSecond() const; // millisecond in minute (0-999)
    int GetMicroSecond() const; // microsecond in minute (0-999)
    int GetNanoSecond() const;  // nanosecond in minute (0-999), step of 100ns
    int GetDayOfWeek() const;   // 1=Sun, 2=Mon, ..., 7=Sat
    int GetDayOfYear() const;   // days since start of year, Jan 1 = 1
 
    // formatting
 
//#if defined(USE_MFC)
    CString Format(LPCTSTR lpszFormat) const;
    CString Format(UINT nFormatID) const;
    CString Format( DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT ) const;
    CString FormatGmt(LPCTSTR lpszFormat) const;
    CString FormatGmt( UINT nFormatID ) const;
    CString FormatGmt( DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT ) const;
//#endif // defined(USE_MFC)
    // This function is not complete yet.. it can not show milli.micro or nanoseconds
    // but the rest works
    LPCTSTR Format(LPTSTR pszBuffer, int iBufferLen, LPCTSTR pszFormat) const;
 
public:
    HighTimeStatus   m_status;
    LARGE_INTEGER    m_liTime;
 
public:
    bool LocalTime();
    bool GmtTime();
    bool ParseDateTime(LPCTSTR lpszDate, DWORD dwFlags = 0);
    static BOOL TmFromOleDate(DATE dtSrc, struct tm& tmDest);
    static BOOL OleDateFromTm(WORD wYear, WORD wMonth, WORD wDay, WORD wHour, WORD wMinute, WORD wSecond, DATE& dtDest);
#if defined(USE_MFC)
#ifdef _DEBUG
//    friend CDumpContext& AFXAPI operator<<(CDumpContext& dc,CHighTime dateSrc);
#endif
    friend CArchive& AFXAPI operator<<(CArchive& ar, CHighTime dateSrc);
    friend CArchive& AFXAPI operator>>(CArchive& ar, CHighTime& dateSrc);
#endif
 
private:
    struct _HighTimeFormat {
            int  nYear;
            UINT nMonth;
            UINT nDay;
            UINT nHour;
            UINT nMinute;
            UINT nSecond;
            UINT nMilli;
            UINT nMicro;
            UINT nNano;
            UINT nDayOfYear;
            UINT nDayOfWeek;
    };
 
    static int anMonthDayInYear[13];
    static BOOL ConvertTimeToLongLong(const _HighTimeFormat  &SrcTime,
                                      LARGE_INTEGER &liDestTime);
    static BOOL ConvertLongLongToTime(const LARGE_INTEGER &liSrcTime,
                                       _HighTimeFormat  &DestTime);
    static void ConvertToStandardFormat(_HighTimeFormat &tmTempHigh, tm &tmTemp);
 
    // String helper functions
    static int FindStr(LPCTSTR pszSource, LPCTSTR pszSub, int nStart);
    static int ReplaceStr(LPTSTR pszDest, int nDestSize, LPCTSTR pszMask, LPCTSTR pszSource);
 
    friend class CHighTimeSpan;
}; //class CHighTime
 
#if defined(USE_MFC)
// CHighTime diagnostics and serialization
#ifdef _DEBUG
//CDumpContext& AFXAPI operator<<(CDumpContext& dc,CHighTime dateSrc);
#endif
CArchive& AFXAPI operator<<(CArchive& ar, CHighTime dateSrc);
CArchive& AFXAPI operator>>(CArchive& ar, CHighTime& dateSrc);
#endif //defined(USE_MFC)
 
class AFX_EXT_CLASS CHighTimeSpan
{
public:
    enum HighTimeSpanStatus {
       valid = 0,
       invalid = 1,
       null = 2,
    };
 
    CHighTimeSpan();
    CHighTimeSpan(const LONGLONG dateSrcSpan);
    CHighTimeSpan(const LARGE_INTEGER dateSrcSpan);
#if defined(USE_MFC)
    CHighTimeSpan(const COleDateTimeSpan &dateSrcSpan);
    CHighTimeSpan(const CTimeSpan &dateSrcSpan);
#endif
    CHighTimeSpan(const CHighTimeSpan &dateSrcSpan);
    CHighTimeSpan(long lDays, int nHours, int nMins, int nSecs,
                  int nMilli = 0, int nMicro = 0, int nNano = 0);
 
    // Operations
public:
    void SetStatus(HighTimeSpanStatus status) { m_status = status; }
    HighTimeSpanStatus GetStatus() const {return m_status;}
 
    void SetHighTimeSpan(long lDays, int nHours, int nMins, int nSecs,
                                     int nMillis = 0, int nMicros = 0, int nNanos = 0);
 
    LONGLONG GetTotalDays() const;    // span in days (about -3.65e6 to 3.65e6)
    LONGLONG GetTotalHours() const;   // span in hours (about -8.77e7 to 8.77e6)
    LONGLONG GetTotalMinutes() const; // span in minutes (about -5.26e9 to 5.26e9)
    LONGLONG GetTotalSeconds() const; // span in seconds (about -3.16e11 to 3.16e11)
    LONGLONG GetTotalMilliSeconds() const; // span in milliseconds
    LONGLONG GetTotalMicroSeconds() const; // span in microseconds
    LONGLONG GetTotalNanoSeconds() const; // span in nanoseconds
 
    int GetDays() const;       // component days in span
    int GetHours() const;      // component hours in span (-23 to 23)
    int GetMinutes() const;    // component minutes in span (-59 to 59)
    int GetSeconds() const;    // component seconds in span (-59 to 59)
    int GetMilliSeconds() const; // component Milliseconds in span (-999 to 999)
    int GetMicroSeconds() const; // component Microseconds in span (-999 to 999)
    int GetNanoSeconds() const;  // component Nanoseconds in span (-900 to 900)
 
    bool IsNegative() const;
 
    // formatting
    LPTSTR Format(LPTSTR pszBuffer, int iBufferLen, LPCTSTR pFormat) const;
//#if defined(USE_MFC)
    CString Format(LPCTSTR pFormat) const;
    CString Format(UINT nID) const;
//#endif
 
    // operators
public:
    const CHighTimeSpan& operator=(LARGE_INTEGER dateSpanSrc);
    const CHighTimeSpan& operator=(LONGLONG dateSpanSrc);
    const CHighTimeSpan& operator=(const CHighTimeSpan& dateSpanSrc);
#if defined(USE_MFC)
    const CHighTimeSpan& operator=(const COleDateTimeSpan& dateSpanSrc);
    const CHighTimeSpan& operator=(const CTimeSpan& dateSpanSrc);
#endif
 
    bool operator==(const CHighTimeSpan& dateSpan) const;
    bool operator!=(const CHighTimeSpan& dateSpan) const;
    bool operator<(const CHighTimeSpan& dateSpan) const;
    bool operator>(const CHighTimeSpan& dateSpan) const;
    bool operator<=(const CHighTimeSpan& dateSpan) const;
    bool operator>=(const CHighTimeSpan& dateSpan) const;
 
    // CHighTimeSpan math
    CHighTimeSpan operator+(const CHighTimeSpan& dateSpan) const;
    CHighTimeSpan operator-(const CHighTimeSpan& dateSpan) const;
    const CHighTimeSpan& operator+=(const CHighTimeSpan dateSpan);
    const CHighTimeSpan& operator-=(const CHighTimeSpan dateSpan);
    CHighTimeSpan operator-() const;
 
    operator LARGE_INTEGER() const {return m_liSpan;}
    operator LONGLONG() const {return m_liSpan.QuadPart;}
#if defined(USE_MFC)
    operator COleDateTimeSpan() const;
    operator CTimeSpan() const;
    const COleDateTimeSpan GetCOleDateTimeSpan(bool bAdjusted=false) const;
#endif //defined(USE_MFC)
 
public:
    HighTimeSpanStatus m_status;
    LARGE_INTEGER      m_liSpan;
 
public:
#if defined(USE_MFC)
#ifdef _DEBUG
//    friend CDumpContext& AFXAPI operator<<(CDumpContext& dc,CHighTimeSpan dateSpanSrc);
#endif
    friend CArchive& AFXAPI operator<<(CArchive& ar, CHighTimeSpan dateSpanSrc);
    friend CArchive& AFXAPI operator>>(CArchive& ar, CHighTimeSpan& dateSpanSrc);
#endif
 
private:
    friend class CHighTime;
}; // class CHighTimeSpan
 
#if defined(USE_MFC)
// CHighTimeSpan diagnostics and serialization
#ifdef _DEBUG
//CDumpContext& AFXAPI operator<<(CDumpContext& dc,CHighTimeSpan dateSpanSrc);
#endif
CArchive& AFXAPI operator<<(CArchive& ar, CHighTimeSpan dateSpanSrc);
CArchive& AFXAPI operator>>(CArchive& ar, CHighTimeSpan& dateSpanSrc);
#endif //defined(USE_MFC)
 
#include "hightime.inl"
 
#endif // !defined(_HIGHTIME_H_)