1 /* "CodeWorker": a scripting language for parsing and generating text. 2 3 Copyright (C) 1996-1997, 1999-2002 C�dric Lemaire 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 To contact the author: codeworker@free.fr 20 */ 21 22 #ifndef _UtlDate_h_ 23 #define _UtlDate_h_ 24 25 #include <string> 26 27 namespace CodeWorker { 28 class UtlInternalDate; 29 30 31 class UtlDate { 32 private: 33 UtlInternalDate* _pInternalDate; 34 35 public: 36 UtlDate(); 37 UtlDate(const UtlDate& date); 38 UtlDate(double dWINGZDate); 39 UtlDate(int iWinfrontDate); 40 UtlDate(int iDay, int iMonth, int iYear, int iHour = 0, int iMin = 0, int iSec = 0, int iMillis = 0); 41 UtlDate(int iFrequency, char cUnit); 42 43 ~UtlDate(); 44 45 bool isNull() const; 46 void nullify(); 47 bool isInfinite() const; 48 void infinity(); 49 50 UtlDate* copyInstance() const; 51 UtlDate& operator =(const UtlDate& date); 52 bool operator <(const UtlDate& date) const; 53 bool operator <=(const UtlDate& date) const; 54 bool operator ==(const UtlDate& date) const; 55 bool operator !=(const UtlDate& date) const; 56 bool operator >=(const UtlDate& date) const; 57 bool operator >(const UtlDate& date) const; 58 59 double operator -(const UtlDate& date) const; 60 61 void today(); 62 63 bool isAFixedDate() const; 64 bool isAVariableDate() const; 65 66 int getFrequency(); 67 char getUnit(); 68 const std::string& getComment() const; 69 void setComment(const std::string& sComment); 70 71 int getDay() const; 72 const char* getWeekDay() const; 73 int getWeekDayOrder() const; 74 int getMonth() const; 75 int getYear() const; 76 77 void setDay(int iDay); 78 void setMonth(int iMonth); 79 void setYear(int iYear); 80 81 void addDay(int iDay); 82 void addMonth(int iMonth); 83 void addYear(int iYear); 84 85 int getHour() const; 86 int getMin() const; 87 int getSec() const; 88 int getMillis() const; 89 90 bool isLastDayOfMonth() const; 91 void setLastDayOfMonth(); 92 93 void ignoreHours(); 94 void setTime(int iHour, int iMin, int iSec, int iMillis = 0); 95 int compareTime(const UtlDate& date) const; 96 void setHour(int iHour); 97 void setMin(int iMin); 98 void setSec(int iSec); 99 void setMillis(int iMillis); 100 101 void addHour(int iHour); 102 void addMin(int iMin); 103 void addSec(int iSec); 104 void addMillis(int iMillis); 105 void addDateFromFormat(const std::string& sFormat, const std::string& sDate); 106 107 std::string getString() const; 108 std::string getMCLDate() const; 109 std::string getFormattedDate(const std::string& sFormat) const; 110 static UtlDate getDateFromFormat(const std::string& sDate, const std::string& sFormat); 111 int getDayWINGZDate() const; 112 double getWINGZDate() const; 113 void setWINGZDate(double dWINGZDate); 114 115 private: 116 static int getInteger(const std::string& sValue, int iNbMaxOfDigits, std::string::size_type& iCursor); 117 static double getDouble(const std::string& sValue, int iNbMaxOfDigits, std::string::size_type& iCursor); 118 }; 119 } 120 121 #endif 122