00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _SWORD_TIME_DATEOPERATION_
00020 #define _SWORD_TIME_DATEOPERATION_
00021
00022 #include "time.HolidayManager.h"
00023
00024 namespace sword {
00025
00027
00056 class SWORDDECL DateOperation {
00057 public:
00058 DateOperation();
00059 DateOperation(const std::string& description);
00060 ~DateOperation();
00061
00062
00063
00064 enum BDC { bdcNone, bdcModf, bdcNext, bdcPrev, bdcInvalid };
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 std::string toString() const;
00081 bool empty() const;
00082 bool emptyDelay() const;
00083 bool emptyBdc() const;
00084 bool valid() const;
00085
00086
00087 void parse(const std::string& description);
00088 void clear();
00089 void neg();
00090 void invalidates();
00091
00092
00093 int days() const;
00094 bool workDays() const;
00095 int months() const;
00096 bool monthEndToEnd() const;
00097 int years() const;
00098 bool yearEndToEnd() const;
00099 BDC bdc() const;
00100 PHolidayRepository holidays() const;
00101
00102
00103 void days(int days);
00104 void workDays(bool workDays);
00105 void months(int months);
00106 void monthEndToEnd(bool endToEnd);
00107 void years(int years);
00108 void yearEndToEnd(bool endToEnd);
00109 void bdc(BDC bdc);
00110 void holidays(const std::string& holidaysName);
00111 void holidays(PHolidayRepository holidays);
00112
00113
00114 void apply(Date& date, int times=1) const;
00115 void applyDelay(Date& date, int times=1) const;
00116 void applyBdc(Date& date) const;
00117 double fraction() const;
00118
00119
00120 static void addWorkDays(Date& date, int days, const HolidayRepository& holidays);
00121 static void addWorkDayModified(Date& date, const HolidayRepository& holidays);
00122
00123
00124 class SyntaxException : public Exception {};
00125
00126 private:
00127 int years_;
00128 bool yearEndToEnd_;
00129 int months_;
00130 bool monthEndToEnd_;
00131 int days_;
00132 bool workDays_;
00133
00134 BDC bdc_;
00135 PHolidayRepository holidays_;
00136 };
00137
00138 }
00139
00140 #include "sword.private/time.DateOperation.inl"
00141
00142 #endif // _SWORD_TIME_DATEOPERATION_