Dear Victor, I may remind you: the Julian Day Count is used very often in astronomy and astrophysics. I use a simple c++-class using a c-program, counting days from ~4700 B.C. to a given date, taking into account all possible calender modifications (julian to gregorian calendar reformation included). This day count is the Julian Day Number (not from Julius Caesar, but another man with the same name ;-)). With this, you can easily synchronize many celestial events ... (and break it down to a milli-second level) on a common time scale. This is very common in astronomy. Greetings, Marc -----Ursprüngliche Nachricht----- Von: Victor Perevoztchikov [mailto:perev@bnl.gov] Gesendet: Freitag, 19. Mai 2000 16:34 An: Eddy Offermann Cc: Steve Lautenschlager; roottalk@pcroot.cern.ch Betreff: Re: [ROOT] Time Graphs. Need for another Date class in ROOT? Hi Eddy, > Long_t JulianDateToBusinessDate(Long_t julianDate); probably not very good name. Julian calendar still used only by Russian and Greek orthodox cherch. You probably mean Gregorian calendar, by the name of pop Gregory who changed Julian calender (13 day difference) Victor Eddy Offermann wrote: > > Hi Steve, > > The class in my little example was to convert between dates given in > mm/dd/yy or mm/dd/yyyy format and business days (skipping saturdays and sundays). > Its use is probably only for the financial world, maybe interesting to incorporate > in a more general date time class. Its layout is as follows: > > #ifndef ROOT_DATE > #define ROOT_DATE > > ////////////////////////////////////////////////////////////////////////// > // // > // TSDate // > // // > // Class implementing interface to convert between calender // > // and bussines days // > // // > ////////////////////////////////////////////////////////////////////////// > > #include <stdlib.h> > > #include "TObject.h" > #include "TMath.h" > #include "TString.h" > > class TSDate : public TObject > { > > protected: > Long_t fBusinessDate; // business date number > > void Copy(TObject& obj); > > private: > Long_t JulianDateToBusinessDate(Long_t julianDate); > Long_t BusinessDateToJulianDate(Long_t businessDate); > Long_t StringToBusinessDate(const Char_t string[]); > Long_t StringToJulianDate(const Char_t string[]); > Char_t* JulianDateToString(Long_t julianDate); > Char_t* BusinessDateToString(Long_t businessDate); > Int_t FromString(const Char_t *string, Int_t &month, Int_t &day, Int_t &year); > > public: > TSDate(); > TSDate(Long_t dayNr); > TSDate(const Char_t* dayString); > TSDate(const TSDate& date); > virtual ~TSDate(); > > void SetDate (Long_t dayNr); > void SetDate (const Char_t* dayString); > Long_t const GetDateNr () const { return fBusinessDate; } > Int_t const GetYear (); > Int_t const GetMonth (); > Int_t const GetDay (); > void GetDateSpan (Long_t dayNr, Int_t &dMonth, Int_t &dDay, Int_t &dYear); > void GetDateSpan (const Char_t* dateString, Int_t &dMonth, Int_t &dDay, Int_t &dYear); > const Char_t* > GetDateString (); > > TSDate& operator=(const TSDate &date); > > friend TSDate MinDate(TSDate &date1, TSDate &date2); > friend TSDate MaxDate(TSDate &date1, TSDate &date2); > > ClassDef(TSDate,0) //Conversion from and to bussiness dates > }; > > #endif > > Eddy -- Victor M. Perevoztchikov perev@bnl.gov perev@vxcern.cern.ch Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 11973-5000 tel office : 631-344-7894; fax 631-344-4206; home 631-345-2690
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:25 MET