Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

date.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           hbcidate.h  -  description
00003                              -------------------
00004     begin                : Fri Aug 3 2001
00005     copyright            : (C) 2001 by fabian kaiser
00006     email                : fabian.kaiser@gmx.de
00007 
00008  ***************************************************************************
00009  *                                                                         *
00010  *   This library is free software; you can redistribute it and/or         *
00011  *   modify it under the terms of the GNU Lesser General Public            *
00012  *   License as published by the Free Software Foundation; either          *
00013  *   version 2.1 of the License, or (at your option) any later version.    *
00014  *                                                                         *
00015  *   This library is distributed in the hope that it will be useful,       *
00016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00018  *   Lesser General Public License for more details.                       *
00019  *                                                                         *
00020  *   You should have received a copy of the GNU Lesser General Public      *
00021  *   License along with this library; if not, write to the Free Software   *
00022  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00023  *   MA  02111-1307  USA                                                   *
00024  *                                                                         *
00025  ***************************************************************************/
00026 
00027 #ifndef HBCIDATE_H
00028 #define HBCIDATE_H
00029 
00035 #ifdef __cplusplus
00036 #include <string>
00037 #endif /* __cplusplus */
00038 
00039 #ifdef TM_IN_SYS_TIME
00040 #  include <sys/time.h>
00041 #else
00042 #  include <time.h>
00043 #endif
00044 #include <openhbci/dllimport.h>
00045 
00046 #ifdef __cplusplus
00047 using namespace std;
00048 
00049 namespace HBCI {
00050 class Time;
00051 
00057 class DLLIMPORT Date {
00058 public:
00065     Date(int day, int month, int year);
00067     Date();
00088     Date(const string &str, int yearsize=4);
00092     Date(const struct tm *tm);
00093 
00104     bool isValid() const;
00105 
00108     string toString() const;
00109 
00115     int day() const { return _day;};
00116 
00123     int month() const {return _month;};
00124 
00131     int year() const { return _year;};
00132 
00138     struct tm to_tm() const;
00139 
00144     time_t to_time_t() const;
00145 
00157     int compare(const Date &d) const;
00158 
00172     int compareTime(const Time& t1, const Date& d2, const Time& t2) const;
00173 
00177     /* void setDate(int day, int month, int year); */
00178     /* -- uh, this seems to have disappeared! cstim, 2002/05/29 */
00179 
00180 private:
00181     int _day;
00182     int _month;
00183     int _year;
00184 };
00185 
00186 
00188 inline bool operator<(const Date &d1, const Date &d2) {
00189     return d1.compare(d2)<0;
00190 }
00191 
00192 
00194 inline bool operator>(const Date &d1, const Date &d2) {
00195     return d1.compare(d2)>0;
00196 }
00197 
00198 
00200 inline bool operator==(const Date &d1, const Date &d2) {
00201     return d1.compare(d2)==0;
00202 }
00203 
00204 } /* namespace HBCI */
00205 typedef struct HBCI::Date HBCI_Date;
00206 
00207 #else /* __cplusplus */
00208 typedef struct Date HBCI_Date;
00209 #endif /* __cplusplus */
00210 
00211 #ifdef __cplusplus
00212 extern "C" {
00213 #endif /* __cplusplus */
00214 
00216     extern HBCI_Date * HBCI_Date_new(const struct tm *tm);
00217     extern HBCI_Date * HBCI_Date_new_blank();
00218     extern HBCI_Date *HBCI_Date_new_string(const char *s, int yearsize);
00219     extern int HBCI_Date_isValid(const HBCI_Date *h);
00220     extern void HBCI_Date_delete(HBCI_Date *d);
00221     extern struct tm HBCI_Date_to_tm(const HBCI_Date *d);
00222     extern time_t HBCI_Date_to_time_t(const HBCI_Date *d);
00223     extern int HBCI_Date_compare(const HBCI_Date *d1, const HBCI_Date *d2);
00225 #ifdef __cplusplus
00226 }
00227 #endif /* __cplusplus */
00228     
00229 
00230 
00231 #ifdef __cplusplus
00232 
00233 namespace HBCI {
00234 
00239 class DLLIMPORT Time {
00240   public:
00241     Time(int hour, int min, int sec);
00242     Time(const string &hbciTimeFormat);
00243     Time(const struct tm *tm);
00244     Time();
00245     
00248     string toString() const;
00250     int hour() const { return _hour;};
00252     int minute() const { return _min;};
00254     int second() const { return _sec;};
00255 
00265     int compare(const Time &t) const;
00266 
00272     struct tm to_tm() const;
00273 
00274 private:
00275         int _hour;
00276         int _min;
00277         int _sec;
00278 };
00279 
00280 
00282 inline bool operator<(const Time &t1, const Time &t2) {
00283     return t1.compare(t2)<0;
00284 }
00285 
00286 
00288 inline bool operator>(const Time &t1, const Time &t2) {
00289     return t1.compare(t2)>0;
00290 }
00291 
00292 
00294 inline bool operator==(const Time &t1, const Time &t2) {
00295     return t1.compare(t2)==0;
00296 }
00297 
00298 
00299 } /* namespace HBCI */
00300 typedef struct HBCI::Time HBCI_Time;
00301 
00302 #else /* __cplusplus */
00303 typedef struct HBCI_Time HBCI_Time;
00304 #endif /* __cplusplus */
00305 
00306 
00307 #ifdef __cplusplus
00308 extern "C" {
00309 #endif /* __cplusplus */
00310 
00312     extern HBCI_Time * HBCI_Time_new(const struct tm *tm);
00313     extern void HBCI_Time_delete(HBCI_Time *d);
00314     extern struct tm HBCI_Time_to_tm(const HBCI_Time *d);
00315     extern struct tm HBCI_DateTime_to_tm(const HBCI_Date *d,
00316                                         const HBCI_Time *t);
00321     extern time_t HBCI_DateTime_to_time_t(const HBCI_Date *d,
00322                                           const HBCI_Time *t);
00323     extern int HBCI_Date_compareTime(const HBCI_Date *d1, const HBCI_Time *t1,
00324                                      const HBCI_Date *d2, const HBCI_Time *t2);
00326 #ifdef __cplusplus
00327 }
00328 #endif /* __cplusplus */
00329 
00330 #endif

Generated on Mon Jun 23 13:41:07 2003 for openhbci by doxygen1.2.17