Hi Fons and rooters, I am using TDate class in my R-Quant. As you know, R-Quant is about Finance and of course I need a "business" date class. My TDate is in fact ZDate adopted for ROOT. ZDate is a well known c++ date manipulation class (under gnu license). TDate will be available under R-Quant license agreement as soon as I solve some remaining questions with the ROOT development team. Meanwhile you can take a look at the header of the class. I removed some features which I do not need in finance (like moon phase :)) but I can put them back in a generic TDate for ROOT. PS. In finance people usually use either daily or intraday data. Therefore it is useful to have separate TDate and TTime classes, so that a user can choose what he/she needs or use both classes in case of "mixed" applications. It is also useful to be able to construct TDatime(TDate Date, TTime Time). Best regards, Anton #ifndef _TDate #define _TDate #include "TObject.h" #include "TString.h" #include <time.h> typedef enum { Jan = 1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec } TMonth; typedef enum { Mon = 1, Tue, Wed, Thu, Fri, Sat, Sun } TWeekDay; struct TDateEntry { Int_t fDay; TMonth fMonth; Int_t fYear; }; class TDate : public TObject { public: TDate(); TDate(TMonth Month, Int_t Day, Int_t Year); TDate(Int_t DayOfYear, Int_t Year); TDate(const TDate &Date); TDate(ULong_t DayNumber); TDate(ULong_t Date, Text_t* Pattern); TDate(const struct tm *Date); TDate AddMonths(Int_t MonthNumber); TDate AddWeeks(Int_t WeekNumber); TDate AddYears(Int_t YearNumber); TDate BeginDST(); static TDate BeginDST(Int_t Year); Int_t Day(); ULong_t DayNumber(); TWeekDay DayOfWeek(); Int_t DayOfYear(); Int_t DaysInMonth(); static Int_t DaysInMonth(TMonth Month, Int_t Year); Int_t DaysInYear(); static Int_t DaysInYear(Int_t Year); TDate EndDST(); static TDate EndDST(Int_t Year); Bool_t IsDST(); static Bool_t IsDST(TDate &Date); Bool_t IsLeapYear(); static Bool_t IsLeapYear(Int_t year); Bool_t IsValid(); static Bool_t IsValid(TMonth Month, Int_t Day, Int_t Year); TMonth Month(); Bool_t operator!=(const TDate &Date) const; TDate operator+(Int_t DayNumber) const; TDate operator+(long DayNumber) const; TDate operator++(); TDate operator++(int); TDate& operator+=(Int_t DayNumber); TDate& operator+=(long DayNumber); long operator-(const TDate &Date) const; TDate operator-(Int_t DayNumber) const; TDate operator-(long DayNumber) const; TDate operator--(); TDate operator--(int); TDate& operator-=(Int_t DayNumber); TDate& operator-=(long DayNumber); Bool_t operator<(const TDate &Date) const; Bool_t operator<=(const TDate &Date) const; TDate& operator=(const TDate &Date); Bool_t operator==(const TDate &Date) const; Bool_t operator>(const TDate &Date) const; Bool_t operator>=(const TDate &Date) const; TDate& operator=(const ULong_t DayNumber); Bool_t operator==(const ULong_t DayNumber) const; Bool_t operator!=(const ULong_t DayNumber) const; static void SetBeginDST(TMonth Month, TWeekDay WeekDay); static void SetEndDST(TMonth Month, TWeekDay WeekDay); static TDate Today(); Int_t WeekOfMonth(); Int_t WeekOfYear(); Int_t WeeksInYear(); static Int_t WeeksInYear(Int_t Year); Int_t Year(); UInt_t Convert(); void Print(const char* Option = ""); // Pope Gregor XIII's reform cancelled 10 days: // the day after Oct 4 1582 was Oct 15 1582 static const Int_t ReformYear; static const TMonth ReformMonth; static const ULong_t ReformDayNumber; protected: // Daylight Savings Time Month and Day of Week static TMonth BeginDSTMonth; static TWeekDay BeginDSTDay; static TMonth EndDSTMonth; static TWeekDay EndDSTDay; protected: TDate Set(TMonth Month, Int_t Day, Int_t Year); ULong_t MakeDayNumber(TDateEntry *DateEntry); TDateEntry* FromDayNumber(ULong_t DayNumber); private: ULong_t fDayNumber; ClassDef(TDate,1) }; inline ULong_t TDate::DayNumber() { return fDayNumber; } #endif
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:25 MET