00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _UXTIMETM_HPP_
00019 #define _UXTIMETM_HPP_
00020
00021 #include <wchar.h>
00022
00023 namespace Ux {
00024
00025
00026
00027
00028
00029 class Timet : public Base {
00030 protected:
00031 time_t tt;
00032
00033 public:
00034 Timet()
00035 : tt(0)
00036 { }
00037 operator time_t() const
00038 { return tt; }
00039 void set(time_t t)
00040 { tt = t; }
00041 void set(void)
00042 { tt = time(); }
00043 double difftime(time_t time0);
00044 static time_t time(void);
00045 };
00046
00047 class Timetm;
00048
00049
00050
00051
00052
00053 class Timestr : public Base {
00054 friend Timetm;
00055
00056 protected:
00057 char timestr[26];
00058
00059 public:
00060 Timestr()
00061 {
00062 clear();
00063 }
00064 void clear(void)
00065 {
00066 timestr[0] = '\0';
00067 }
00068 operator const char*() const
00069 { return timestr; }
00070 const char *ctime(const time_t *t = NULL, bool keep_nl = true);
00071
00072
00073
00074 const char *ctime(time_t t, bool keep_nl = true)
00075 { return ctime(&t, keep_nl); }
00076 };
00077
00078
00079
00080
00081
00082 class Timetm : public tm, public Base {
00083 protected:
00084 Timestr str;
00085
00086 public:
00087
00088
00089
00090 Timetm(time_t t = 0)
00091 {
00092 localtime(t);
00093 }
00094 operator const char*()
00095 { return asctime(false); }
00096 void set(const struct tm& t);
00097 time_t mktime(void);
00098 const char *asctime(bool keep_nl = true);
00099 void getdate(const char *s);
00100 void gmtime(const time_t *t = NULL);
00101
00102
00103
00104 void gmtime(time_t t)
00105 { return gmtime(&t); }
00106 void localtime(const time_t *t = NULL);
00107
00108
00109
00110 void localtime(time_t t)
00111 { return localtime(&t); }
00112 char *strptime(const char *s, const char *format);
00113 size_t strftime(char *buf, size_t bufsize, const char *format);
00114 size_t wcsftime(wchar_t *buf, size_t bufsize, const wchar_t *format);
00115 };
00116
00117
00118
00119
00120
00121 class Timeval : public timeval, public Base {
00122 public:
00123 void gettimeofday(void);
00124 };
00125
00126 }
00127
00128 #endif // _UXTIMETM_HPP_