rvm 1.08
|
00001 #ifndef __tstamp_h__ 00002 #define __tstamp_h__ 00003 00004 #ifdef HAVE_SYS_TIME_H 00005 #include <sys/types.h> 00006 #endif 00007 #include <time.h> 00008 00009 #include "asserts.h" 00010 #include "types.h" 00011 00012 /** Timestamp object */ 00013 class timestamp 00014 { 00015 public: 00016 enum resolution_type { 00017 resolution_year, 00018 resolution_month, 00019 resolution_day, 00020 resolution_hour, 00021 resolution_minute, 00022 resolution_second 00023 }; 00024 00025 timestamp(); 00026 timestamp(const timestamp& a_t); 00027 timestamp( 00028 const int a_year, 00029 const int a_month, 00030 const int a_day, 00031 const int a_hour, 00032 const int a_minute, 00033 const int a_second 00034 ); 00035 timestamp(const std::string& a_s); 00036 00037 void set(void); 00038 void assign(const timestamp& a_t); 00039 void assign( 00040 const int a_year, 00041 const int a_month, 00042 const int a_day, 00043 const int a_hour, 00044 const int a_minute, 00045 const int a_second 00046 ); 00047 void assign(const std::string& a_s); 00048 void clear(void); 00049 void resolution(resolution_type a_r); 00050 resolution_type resolution(void) const; 00051 00052 const std::string str(void) const; 00053 const std::string str(const resolution_type a_resolution) const; 00054 int second(void) const; 00055 int minute(void) const; 00056 int hour(void) const; 00057 int day(void) const; 00058 int month(void) const; 00059 int year(void) const; 00060 00061 timestamp& operator = (const timestamp& a_t); 00062 timestamp& operator = (const std::string& a_s); 00063 bool operator < (const timestamp& a_t) const; 00064 bool operator > (const timestamp& a_t) const; 00065 bool operator == (const timestamp& a_t) const; 00066 00067 private: 00068 int m_year; 00069 int m_month; 00070 int m_day; 00071 int m_hour; 00072 int m_minute; 00073 int m_second; 00074 resolution_type m_resolution; 00075 00076 const std::string make_str_(const int a_resolution) const; 00077 }; 00078 00079 bool is_timestamp(const std::string& a_s); 00080 00081 /** A null timestamp */ 00082 const timestamp null_timestamp(0,1,1,0,0,0); 00083 00084 /** The minimum timestamp value */ 00085 const timestamp min_timestamp(null_timestamp); 00086 00087 /** The maximum timestamp value */ 00088 const timestamp max_timestamp(9999,12,31,23,59,59); 00089 00090 #endif