00001 #ifndef _CTBtime_HXX
00002 #define _CTBtime_HXX 1
00003
00008
00009
00010
00011
00012
00013
00014
00015
00016 class CTBtime {
00017 public:
00018 CTBtime();
00019 CTBtime(double d_time);
00020
00021 void GetSystemTime();
00022
00023 void Split(CTBint32& i_sec, CTBint32& i_usec) const;
00024
00025 bool Valid() const;
00026 CTBint32 UnixTime() const;
00027
00028 void ToStream(ostream& os) const;
00029 void FromStream(istream& is);
00030
00031 bool operator!() const;
00032
00033 CTBtime& operator=(double d_time);
00034 CTBtime& operator+=(double d_delta);
00035 CTBtime& operator-=(double d_delta);
00036
00037 operator double () const;
00038
00039 friend CTBtime operator+(const CTBtime& time, double d_delta);
00040 friend CTBtime operator+(double d_delta, const CTBtime& time);
00041 friend CTBtime operator-(const CTBtime& time, double d_delta);
00042 friend double operator-(const CTBtime& lhs, const CTBtime& rhs);
00043
00044 friend bool operator==(const CTBtime& lhs, const CTBtime& rhs);
00045 friend bool operator<(const CTBtime& lhs, const CTBtime& rhs);
00046
00047 public:
00048 static CTBint32 ymdhms2ui(int i_year, int i_month, int i_day,
00049 int i_hour, int i_min, int i_sec);
00050
00051 static CTBint32 vms2ui(const char* c_time);
00052
00053 static void ui2local(char* c_time, int i_size,
00054 const char* c_format, CTBint32 i_time);
00055 static void ui2utc(char* c_time, int i_size,
00056 const char* c_format, CTBint32 i_time);
00057
00058 static void ui2vms(char c_time[21], CTBint32 i_time);
00059
00060 private:
00061 double md_time;
00062
00063 };
00064
00065 ostream& operator<<(ostream& os, const CTBtime& obj);
00066 istream& operator>>(istream& is, CTBtime& obj);
00067
00068
00069
00070 class CTBtimeParsed {
00071 public:
00072 CTBtimeParsed();
00073 CTBtimeParsed(const CTBtime& time);
00074
00075 int Year() const;
00076 int Month() const;
00077 int Day() const;
00078 int WeekDay() const;
00079 int YearDay() const;
00080 int Hour() const;
00081 int Minute() const;
00082 int Second() const;
00083 int Microsecond() const;
00084 int TimeZoneOffset() const;
00085 const char* TimeZoneName() const;
00086 bool DaylightSavingTime() const;
00087
00088 void Date(int i_year, int i_month, int i_day);
00089 void Time(int i_hour, int i_min=0, int i_sec=0,
00090 int i_usec=0, int i_dst=-1);
00091 void DateTime(int i_year, int i_month, int i_day,
00092 int i_hour=0, int i_min=0, int i_sec=0,
00093 int i_usec=0, int i_dst=-1);
00094
00095 bool Valid() const;
00096
00097 void ParseTime(const CTBtime& time);
00098 CTBtime MakeTime();
00099
00100 void ToStream(ostream& os) const;
00101 void FromStream(istream& is);
00102
00103 void Dump(int i_indent=0, ostream& os=cout,
00104 const char* p_text=0) const;
00105
00106 bool operator!() const;
00107
00108 CTBtimeParsed& operator=(const CTBtime& time);
00109
00110 operator void* () const;
00111 operator CTBtime() const;
00112
00113 private:
00114 void Init();
00115
00116 private:
00117 int mi_year;
00118 int mi_month;
00119 int mi_day;
00120 int mi_wday;
00121 int mi_yday;
00122 int mi_hour;
00123 int mi_min;
00124 int mi_sec;
00125 int mi_usec;
00126 int mi_tzoffset;
00127 char mc_tzname[8];
00128 int mi_dst;
00129 };
00130
00131 ostream& operator<<(ostream& os, const CTBtimeParsed& obj);
00132 istream& operator>>(istream& is, CTBtimeParsed& obj);
00133
00134 #include "CTBtime.icc"
00135
00136 #endif