Skip to content
Snippets Groups Projects
Commit 46420713 authored by Rene Brun's avatar Rene Brun
Browse files

Implement a suggestion from kerry.t.lee@nasa.gov:

//add implementation of new Set method in TDatime.cxx
void TDatime::Set(const char* sqlDateTime)
   // Expects as input a string in SQL date/time compatible format, like:
   // yyyy-mm-dd hh:mm:ss.


git-svn-id: http://root.cern.ch/svn/root/trunk@18638 27541ba8-7e3a-0410-8455-c3a389f83636
parent 0612a3d3
No related branches found
No related tags found
No related merge requests found
// @(#)root/base:$Name: $:$Id: TDatime.h,v 1.11 2006/05/13 11:00:50 brun Exp $
// @(#)root/base:$Name: $:$Id: TDatime.h,v 1.12 2007/02/04 17:39:44 brun Exp $
// Author: Rene Brun 05/01/95
/*************************************************************************
......@@ -68,6 +68,7 @@ public:
void Set(Int_t date, Int_t time);
void Set(Int_t year, Int_t month, Int_t day,
Int_t hour, Int_t min, Int_t sec);
void Set(const char *sqlDateTime);
Int_t Sizeof() const {return sizeof(UInt_t);}
friend Bool_t operator==(const TDatime &d1, const TDatime &d2);
......
// @(#)root/base:$Name: $:$Id: TDatime.cxx,v 1.12 2006/11/06 09:48:10 rdm Exp $
// @(#)root/base:$Name: $:$Id: TDatime.cxx,v 1.13 2006/12/13 18:06:34 rdm Exp $
// Author: Rene Brun 05/01/95
/*************************************************************************
......@@ -69,15 +69,7 @@ TDatime::TDatime(const char *sqlDateTime)
// Expects as input a string in SQL date/time compatible format, like:
// yyyy-mm-dd hh:mm:ss.
Int_t yy, mm, dd, hh, mi, ss;
if (sscanf(sqlDateTime, "%d-%d-%d %d:%d:%d", &yy, &mm, &dd, &hh, &mi, &ss) == 6)
Set(yy, mm, dd, hh, mi, ss);
else {
Error("TDatime(sqlDatTime)", "input string not in right format, set"
" to current date/time");
Set();
}
Set(sqlDateTime);
}
//______________________________________________________________________________
......@@ -348,6 +340,23 @@ void TDatime::Set(Int_t year, Int_t month, Int_t day,
fDatime = (year-1995)<<26 | month<<22 | day<<17 | hour<<12 | min<<6 | sec;
}
//______________________________________________________________________________
void TDatime::Set(const char* sqlDateTime)
{
// Expects as input a string in SQL date/time compatible format, like:
// yyyy-mm-dd hh:mm:ss.
Int_t yy, mm, dd, hh, mi, ss;
if (sscanf(sqlDateTime, "%d-%d-%d %d:%d:%d", &yy, &mm, &dd, &hh, &mi, &ss) == 6)
Set(yy, mm, dd, hh, mi, ss);
else {
Error("TDatime(sqlDatTime)", "input string not in right format, set"
" to current date/time");
Set();
}
}
//______________________________________________________________________________
void TDatime::Streamer(TBuffer &b)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment