From 464207135091ce53110848ef90dcf31b461888ae Mon Sep 17 00:00:00 2001
From: Rene Brun <Rene.Brun@cern.ch>
Date: Thu, 3 May 2007 08:15:11 +0000
Subject: [PATCH] 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
---
 base/inc/TDatime.h   |  3 ++-
 base/src/TDatime.cxx | 29 +++++++++++++++++++----------
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/base/inc/TDatime.h b/base/inc/TDatime.h
index 42998b269a0..c9d8408e8a0 100644
--- a/base/inc/TDatime.h
+++ b/base/inc/TDatime.h
@@ -1,4 +1,4 @@
-// @(#)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);
diff --git a/base/src/TDatime.cxx b/base/src/TDatime.cxx
index a5154050b81..93e02b88aef 100644
--- a/base/src/TDatime.cxx
+++ b/base/src/TDatime.cxx
@@ -1,4 +1,4 @@
-// @(#)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)
 {
-- 
GitLab