Changeset 12797 for trunk/Mars


Ignore:
Timestamp:
01/31/12 11:26:51 (13 years ago)
Author:
tbretz
Message:
 Allow to feed SetSqlDateTime also with an ISO time and allow more or less than three digits after the dot
Location:
trunk/Mars/mbase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mbase/MTime.cc

    r9564 r12797  
    420420//   "yyyy-mm-dd hh:mm:ss"
    421421//
    422 Bool_t MTime::SetSqlDateTime(const char *str)
    423 {
    424     if (!str)
     422Bool_t MTime::SetSqlDateTime(TString str)
     423{
     424    if (str.IsNull())
    425425        return kFALSE;
    426426
     427    str.ReplaceAll("T", "");
     428
     429    if (str.Contains('.'))
     430        str += "000";
     431
    427432    UInt_t  y, mon, d, h, m, s, ms;
    428433
    429     if (7==sscanf(str, "%04u-%02u-%02u %02u:%02u:%02u.%u", &y, &mon, &d, &h, &m, &s, &ms))
     434    if (7==sscanf(str, "%04u-%02u-%02u %02u:%02u:%02u.%03u", &y, &mon, &d, &h, &m, &s, &ms))
    430435        return Set(y, mon, d, h, m, s, ms);
    431436
  • trunk/Mars/mbase/MTime.h

    r9208 r12797  
    9494    void     Set(const struct timeval &tv);
    9595    Bool_t   SetString(const char *str);
    96     Bool_t   SetSqlDateTime(const char *str);
     96    Bool_t   SetSqlDateTime(TString str);
    9797    Bool_t   SetSqlTimeStamp(const char *str);
    9898    void     SetCT1Time(UInt_t mjd, UInt_t t1, UInt_t t0);
Note: See TracChangeset for help on using the changeset viewer.