00001 00015 #ifndef INC_MI32_RVCDATETIME_H 00016 #define INC_MI32_RVCDATETIME_H 00017 00018 #ifndef INC_MI32_STDDEFNS_H 00019 #include <mi32/stddefns.h> 00020 #endif 00021 00022 #include <time.h> 00023 00024 struct RVCDATETIME { 00025 UINT8 year; 00026 UINT8 month; 00027 UINT8 day; 00028 UINT8 hour; 00029 UINT8 minute; 00030 UINT8 second; 00031 UINT16 count; 00032 00033 int Compare ( 00034 const RVCDATETIME& rhs 00035 ) const { 00036 if (this->year < rhs.year) return (1); 00037 else if (this->year > rhs.year) return (-1); 00038 if (this->month < rhs.month) return (1); 00039 else if (this->month > rhs.month) return (-1); 00040 if (this->day < rhs.day) return (1); 00041 else if (this->day > rhs.day) return (-1); 00042 if (this->hour < rhs.hour) return (1); 00043 else if (this->hour > rhs.hour) return (-1); 00044 if (this->minute < rhs.minute) return (1); 00045 else if (this->minute > rhs.minute) return (-1); 00046 if (this->second < rhs.second) return (1); 00047 else if (this->second > rhs.second) return (-1); 00048 return (0); 00049 } 00050 00051 void SetCurrentTime ( 00052 ) { 00053 time_t curtime; 00054 time(&curtime); 00055 SetTime(curtime); 00056 return; 00057 } 00058 00059 void SetTime ( 00060 const time_t& curtime 00061 ) { 00062 struct tm *tm = localtime(&curtime); 00063 this->year = static_cast<UINT8>(tm->tm_year); 00064 this->month = static_cast<UINT8>(tm->tm_mon + 1); 00065 this->day = static_cast<UINT8>(tm->tm_mday); 00066 this->hour = static_cast<UINT8>(tm->tm_hour); 00067 this->minute = static_cast<UINT8>(tm->tm_min); 00068 this->second = static_cast<UINT8>(tm->tm_sec); 00069 this->count = 0; 00070 return; 00071 } 00072 00073 }; 00074 00075 inline bool operator== ( 00076 const RVCDATETIME& lhs, 00077 const RVCDATETIME& rhs 00078 ) { return (lhs.Compare(rhs) == 0); } 00079 00080 inline bool operator!= ( 00081 const RVCDATETIME& lhs, 00082 const RVCDATETIME& rhs 00083 ) { return (lhs.Compare(rhs) != 0); } 00084 00085 inline bool operator< ( 00086 const RVCDATETIME& lhs, 00087 const RVCDATETIME& rhs 00088 ) { return (lhs.Compare(rhs) == 1); } 00089 00090 inline bool operator<= ( 00091 const RVCDATETIME& lhs, 00092 const RVCDATETIME& rhs 00093 ) { return (lhs.Compare(rhs) != -1); } 00094 00095 inline bool operator> ( 00096 const RVCDATETIME& lhs, 00097 const RVCDATETIME& rhs 00098 ) { return (lhs.Compare(rhs) == -1); } 00099 00100 inline bool operator>= ( 00101 const RVCDATETIME& lhs, 00102 const RVCDATETIME& rhs 00103 ) { return (lhs.Compare(rhs) != 1); } 00104 00105 #endif // INC_MI32_RVCGENINFO_H
1.6.1