00001
00053 #ifndef INC_MI32_DATETIME_H
00054 #define INC_MI32_DATETIME_H
00055
00056 #ifndef INC_MI32_MISTRING_H
00057 #include <mi32/mistring.h>
00058 #endif
00059
00060 #ifndef INC_TIME_H
00061 #include <time.h>
00062 #define INC_TIME_H
00063 #endif
00064
00065
00066 #ifndef GENERATING_DOXYGEN_OUTPUT
00067
00068 struct RVCDATETIME;
00069 #ifdef WIN32
00070 struct _SYSTEMTIME;
00071 struct _FILETIME;
00072 #endif
00073 #endif
00074
00075
00076 #if defined(MISYSTEMDLL)
00077 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00078 #else
00079 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00080 #endif
00081
00084 class CLASSLIBEXPORT DATETIME {
00085 public:
00086 enum FORMAT {
00087 FORMAT_ISO8601_Basic = 0,
00088 FORMAT_ISO8601_Extended = 1,
00089 FORMAT_XML_dateTime = 2,
00090 FORMAT_XML_date = 3,
00091 FORMAT_XML_time = 4,
00092 FORMAT_RFC822 = 5,
00093 FORMAT_Simple = 6,
00094 FORMAT_YYYYMMDD_HHMMSS = 7,
00095 FORMAT_Job = FORMAT_YYYYMMDD_HHMMSS,
00096 };
00097
00098 enum TIME {
00099 TIME_Uninitialized = 0,
00100 TIME_CurrentLocal = 1,
00101 TIME_CurrentUTC = 2
00102 };
00103
00105 DATETIME (
00106 );
00107
00109 DATETIME (
00110 const DATETIME& rhs
00111 );
00112
00115 DATETIME (
00116 TIME value
00117 );
00118
00122 DATETIME (
00123 int year,
00124 int month,
00125 int day
00126 );
00127
00129 DATETIME (
00130 int year,
00131 int month,
00132 int day,
00133 int hour,
00134 int min,
00135 int sec,
00136 bool bIsLocal
00137 );
00138
00141 DATETIME (
00142 const RVCDATETIME& rhs
00143 );
00144
00146 DATETIME (
00147 const struct tm& rhs,
00148 bool bIsLocal
00149 );
00150
00151 #ifdef WIN32
00153 DATETIME (
00154 const struct _SYSTEMTIME& rhs,
00155 bool bIsLocal
00156 );
00157 #endif
00158
00159 #ifdef WIN32
00161 DATETIME (
00162 const struct _FILETIME& rhs,
00163 bool bIsLocal
00164 );
00165 #endif
00166
00169 explicit DATETIME (
00170 time_t value
00171 );
00172
00174 ~DATETIME (
00175 );
00176
00178
00179
00181 DATETIME& operator= (
00182 const DATETIME& rhs
00183 );
00184
00186 DATETIME& operator= (
00187 const RVCDATETIME& rhs
00188 );
00189
00191 DATETIME& operator= (
00192 const time_t rhs
00193 );
00194
00196 DATETIME& operator= (
00197 DATETIME::TIME rhs
00198 );
00199
00201
00202
00203 bool operator== (
00204 const DATETIME& rhs
00205 ) const;
00206
00207 bool operator!= (
00208 const DATETIME& rhs
00209 ) const;
00210
00211 bool operator< (
00212 const DATETIME& rhs
00213 ) const;
00214
00215 bool operator> (
00216 const DATETIME& rhs
00217 ) const;
00218
00219 bool operator<= (
00220 const DATETIME& rhs
00221 ) const;
00222
00223 bool operator>= (
00224 const DATETIME& rhs
00225 ) const;
00226
00227
00229 void Clear (
00230 );
00231
00234 void ConvertToLocal (
00235 );
00236
00239 void ConvertToUTC (
00240 );
00241
00245 void Get (
00246 struct tm& tm,
00247 bool bLocal = false
00248 ) const;
00249
00253 void Get (
00254 RVCDATETIME& dt
00255 ) const;
00256
00257 #ifdef WIN32
00259 void Get (
00260 struct _SYSTEMTIME& st,
00261 bool bLocal = false
00262 ) const;
00263 #endif
00264
00266 INT32 GetYear (
00267 ) const;
00268
00270 UINT32 GetMonth (
00271 ) const;
00272
00274 UINT32 GetDayOfMonth (
00275 ) const;
00276
00278 UINT32 GetHour (
00279 ) const;
00280
00282 UINT32 GetMin (
00283 ) const;
00284
00286 UINT32 GetSec (
00287 ) const;
00288
00290 INT32 GetDateJulian (
00291 ) const;
00292
00295 double GetDateTimeJulian (
00296 ) const;
00297
00300 INT32 GetDateYYYYMMDD (
00301 ) const;
00302
00306 MISTRING GetFormatted (
00307 FORMAT format,
00308 bool IncludeLocal
00309 ) const;
00310
00313 UINT64 GetNanoTime (
00314 ) const;
00315
00317 UINT32 GetTimeOfDay (
00318 bool bLocal
00319 ) const;
00320
00323 time_t GetTimeT (
00324 ) const;
00325
00327 UINT32 GetDayOfWeek (
00328 ) const;
00329
00331 UINT32 GetDayOfYear (
00332 ) const;
00333
00335 bool IsLocalTime (
00336 ) const;
00337
00339 bool IsSet (
00340 ) const;
00341
00344 bool IsUTCTime (
00345 ) const;
00346
00348 bool IsValid (
00349 ) const;
00350
00353 void Set (
00354 const time_t rhs
00355 );
00356
00358 void Set (
00359 const struct tm& rhs,
00360 bool bIsLocal
00361 );
00362
00365 void Set (
00366 const RVCDATETIME& rhs
00367 );
00368
00376 const MIUNICODE* Set (
00377 const MIUNICODE* str,
00378 const char* format = "%c"
00379 );
00380
00381 #ifdef WIN32
00385 void Set (
00386 const struct _SYSTEMTIME& rhs,
00387 bool bIsLocal
00388 );
00389 #endif
00390
00391 #ifdef WIN32
00393 void Set (
00394 const struct _FILETIME& rhs,
00395 bool bIsLocal
00396 );
00397 #endif
00398
00400 void SetBuild (
00401 );
00402
00404 void SetCurrent (
00405 bool bLocalTime = true
00406 );
00407
00409 void SetDate (
00410 INT32 year,
00411 UINT32 month,
00412 UINT32 day
00413 );
00414
00417 void SetDateJulian (
00418 INT32 juliandate
00419 );
00420
00423 void SetDateTimeJulian (
00424 double juliandate
00425 );
00426
00430 void SetFormatted (
00431 const MISTRING& dtstr,
00432 FORMAT format
00433 );
00434
00438 void SetNanoTime (
00439 UINT64 rhs
00440 );
00441
00444 void SetDateYYYYMMDD (
00445 int yyyymmdd
00446 );
00447
00450 void SetTimeOfDay (
00451 UINT32 hour,
00452 UINT32 min,
00453 UINT32 sec,
00454 bool bIsLocal
00455 );
00456
00459 void SetTimeOfDay (
00460 UINT32 SecondsSinceMidnight,
00461 bool bIsLocal
00462 );
00463
00464
00519 void StrfTime (
00520 MISTRING& str,
00521 const char* format,
00522 bool bLocal = true
00523 ) const;
00524
00525 private:
00526 #ifndef GENERATING_DOXYGEN_OUTPUT
00527
00531
00533 void SetHour (
00534 UINT32 val
00535 );
00536
00542 void SetIsLocal (
00543 bool bIsLocal
00544 );
00545
00547 void SetDayOfMonth (
00548 UINT32 val
00549 );
00550
00552 void SetMin (
00553 UINT32 val
00554 );
00555
00557 void SetMonth (
00558 UINT32 val
00559 );
00560
00562 void SetSec (
00563 UINT32 val
00564 );
00565
00567 void SetYear (
00568 INT32 val
00569 );
00570
00573 static time_t TimeTFromTM (
00574 const struct tm*const timeval
00575 );
00576
00577 struct tm m_tm;
00578 bool m_bIsLocal;
00579 #endif // GENERATING_DOXYGEN_OUTPUT
00580 };
00581
00582 #undef CLASSLIBEXPORT
00583
00584 #endif