Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

hk_classes/hk_classes/hk_datetime.h

Go to the documentation of this file.
00001 // ****************************************************************************
00002 // copyright (c) 2000-2005 Horst Knorr <hk_classes@knoda.org>  
00003 // This file is part of the hk_classes library.
00004 // This file may be distributed and/or modified under the terms of the
00005 // GNU Library Public License version 2 as published by the Free Software
00006 // Foundation and appearing in the file COPYING included in the
00007 // packaging of this file.
00008 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00009 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00010 // ****************************************************************************
00011 #ifndef HK_DATETIME
00012 #define HK_DATETIME
00013 #include "hk_class.h"
00014 using namespace std;
00015 
00025 class hk_datetime: public hk_class
00026 {
00027     public:
00028         hk_datetime(void);
00029         hk_datetime(const hk_datetime&);
00030         virtual ~hk_datetime(void){}
00034         bool set_date( int day,  int month,  int year);
00038         bool set_time( int hour, int minute,  int second);
00042         bool set_datetime( int day,  int month,  int year,  int hour, int minute,  int second);
00047         bool set_date_asstring(const hk_string& s);
00051         bool set_time_asstring(const hk_string& s);
00055         bool set_datetime_asstring(const hk_string& s);
00059         hk_string date_asstring(void) const;
00063         hk_string time_asstring(void)const;
00067         hk_string datetime_asstring(void) const;
00075         void set_dateformat(const hk_string& f);
00083         void set_timeformat(const hk_string& f);
00094         void set_datetimeformat(const hk_string& f);
00095 
00096         int day() const {return p_day;}
00097         int month()const{return p_month;}
00098         int year()const{return p_year;}
00099         int hour()const{return p_hour;}
00100         int minute()const{return p_minute;}
00101         int second()const {return p_second;}
00105         void set_now(void);
00106 
00107         bool operator=(const hk_datetime&);
00108         bool operator==(const hk_datetime&);
00109         bool operator!=(const hk_datetime&);
00110         bool operator>(const hk_datetime&);
00111         bool operator>=(const hk_datetime&);
00112         bool operator<(const hk_datetime&);
00113         bool operator<=(const hk_datetime&);
00114 
00118         double difference(const hk_datetime& d);
00119     protected:
00120 
00121         bool is_ok_date( int day,  int month,  int year);
00122         bool is_ok_time( int hour, int minute,  int second);
00123 
00124     private:
00125         void p_dateasstring(void)const ;
00126         void p_timeasstring(void) const;
00127         int  p_setvalue(int &l,const hk_string& s,bool is_date=false);
00128         int p_year,p_month,p_day;
00129         int p_second,p_minute,p_hour;
00130         hk_string p_dateformat;
00131         hk_string p_timeformat;
00132         hk_string p_datetimeformat;
00133         mutable hk_string buffer;
00134         void set_hk_datetime(const hk_datetime&);
00135         bool is_equal(const hk_datetime&);
00136 };
00137 
00138 //void set_format(hk_datetime &dt,int t);
00143 hk_string transfer_date(const hk_string& date,const hk_string& originalformat, const hk_string& targetformat);
00148 hk_string transfer_time(const hk_string& time,const hk_string& originalformat, const hk_string& targetformat);
00153 hk_string transfer_datetime(const hk_string& datetime,const hk_string& originalformat, const hk_string& targetformat);
00154 
00155 ostream& operator<<(ostream&,const hk_datetime&);
00156 ostream& operator<<(ostream&, hk_datetime&);
00157 #endif

Generated on Thu Mar 9 18:40:40 2006 for hk_classes by  doxygen 1.4.1