©2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ux/uxtimetm.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2003 by Marc J. Rochkind. All rights reserved.
00003     May be copied only for purposes and under conditions described
00004     on the Web page www.basepath.com/aup/copyright.htm.
00005 
00006     The Example Files are provided "as is," without any warranty;
00007     without even the implied warranty of merchantability or fitness
00008     for a particular purpose. The author and his publisher are not
00009     responsible for any damages, direct or incidental, resulting
00010     from the use or non-use of these Example Files.
00011 
00012     The Example Files may contain defects, and some contain deliberate
00013     coding mistakes that were included for educational reasons.
00014     You are responsible for determining if and how the Example Files
00015     are to be used.
00016 
00017 */
00018 #ifndef _UXTIMETM_HPP_
00019 #define _UXTIMETM_HPP_
00020 
00021 #include <wchar.h>
00022 
00023 namespace Ux {
00024 
00025 /**
00026     \ingroup Ux
00027     Don't use this class -- use TimeSec instead.
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     \ingroup Ux
00051     Don't use this class -- use TimeString instead.
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         Version of ctime that takes a time_t instead of a pointer to one.
00073     **/
00074     const char *ctime(time_t t, bool keep_nl = true)
00075         { return ctime(&t, keep_nl); }
00076 };
00077 
00078 /**
00079     \ingroup Ux
00080     Don't use this class -- use TimeParts instead.
00081 */
00082 class Timetm : public tm, public Base {
00083 protected:
00084     Timestr str;
00085 
00086 public:
00087     /**
00088         Initializes to local time (at epoch by default).
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         Version of gmtime that takes a time_t instead of a pointer to one.
00103     **/
00104     void gmtime(time_t t)
00105         { return gmtime(&t); }
00106     void localtime(const time_t *t = NULL);
00107     /**
00108         Version of localtime that takes a time_t instead of a pointer to one.
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     \ingroup Ux
00119     Don't use this class -- use TimeMsec instead.
00120 */
00121 class Timeval : public timeval, public Base {
00122 public:
00123     void gettimeofday(void);
00124 };
00125 
00126 } // namespace
00127 
00128 #endif // _UXTIMETM_HPP_

Generated on Fri Apr 23 10:57:07 2004 for AUP2 Example Source by doxygen 1.3.1