00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef HBCIDATE_H
00028 #define HBCIDATE_H
00029
00035 #ifdef __cplusplus
00036 #include <string>
00037 #endif
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
00178
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 }
00205 typedef struct HBCI::Date HBCI_Date;
00206
00207 #else
00208 typedef struct Date HBCI_Date;
00209 #endif
00210
00211 #ifdef __cplusplus
00212 extern "C" {
00213 #endif
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
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 }
00300 typedef struct HBCI::Time HBCI_Time;
00301
00302 #else
00303 typedef struct HBCI_Time HBCI_Time;
00304 #endif
00305
00306
00307 #ifdef __cplusplus
00308 extern "C" {
00309 #endif
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
00329
00330 #endif