Hi Rooters, In agreement with Anton, I would also like to advocate adding TDate and TTime classes to ROOT. It is apparent that there is a need for advanced date and time handling which many users are currently implementing themselves. Here are some thoughts on the subject: --we want to maintain consistent user interface Since ROOT is an object-oriented framework, it makes sense to have needed functionality in classes, with a ROOT consistent interface rather than using c functions like time and date. I think it's fine if one wants to make use of those within the class, but it's best to keep a class-based, consistent interface for the user. Additionally, we can have much more functionality and ease of use with a class interface. --it's nice to have stand alone TDate and TTime clases for users who only need one or the other. TDate can have just one data member, a long int, with the number of Julian Days. In financial applications, if one doesn't need time, one doesn't want to store it. In some cases, there are many instances of a date within a root file and superfluous info can greatly increase the size of the file. --fulfill as many user needs as possible with each class Eddy suggested that the functionality of zDate was overkill, but since ROOT serves many users and many communities it is important to provide for as many needs as possible. Even the phase of the moon can be useful. For example, a few years ago LEP discovered that it's beam energies fluctuated with the phase of the moon. This is only to say that additional functionality is a good thing--so long as it is tested and accurate. --TDate should have one day precision --TTime should have either: 1) variable precision By having two data members "fIncrement" and "fTicks" we can set the fractions of a second that each tick will represent. If fTicks is a long int, this allows for nearly a year at nanosecond precision. 2) Fixed precision with as much precision as can be fit into 24 hours (~10^-14 sec precision with a long int) If one needs high precision for more than a 24 hour period, then they could do something like TDatime(TDate d, TTime t). Unfortunately, TDatime is still limited to dates after 1995 and it seems redundant to put another DateTime class in ROOT with TDate and TTime data members. --references: Discussion of Date algorithms: http://www.capecod.net/~pbaum/date/date0.htm zDate class: http://www.strangecreations.com/library/snippets/ the killer date class: http://www.njtheater.com/JamesCurran/Download/killerc.htm >From: KOSU_FOKIN@garbo.lucas.lu.se >To: roottalk@pcroot.cern.ch >Subject: [ROOT] R-Quant, TDate and "business" date class >Date: Tue, 23 May 2000 21:14:13 +0000 > >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 > > > > > > > > > > > > > > > ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:26 MET