TDatime::Set() SQL DateTime Format

From: Lee, Kerry T. (JSC-SF)[LMIT] <kerry.t.lee_at_nasa.gov>
Date: Wed, 2 May 2007 16:07:02 -0500


Dear ROOT team,

Could you include a Set function for the TDatime class that allows one to set an existing object using the SQL DateTime format? See modified code below.

Thanks
Kerry

//insert following Set method into TDatime.h

void Set(const char *sqlDateTime);

//replace current constructor in TDatime.cxx TDatime::TDatime(const char *sqlDateTime) {

// Expects as input a string in SQL date/time compatible format, like:
// yyyy-mm-dd hh:mm:ss.

  Set(sqlDateTime);
}

//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.

   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();

   }
} Received on Wed May 02 2007 - 23:07:13 CEST

This archive was generated by hypermail 2.2.0 : Thu May 03 2007 - 11:50:02 CEST