Re: Convert a TString in a TDatime

From: Fons Rademakers <Fons.Rademakers_at_cern.ch>
Date: Tue, 29 Nov 2011 12:29:54 +0100


Hi Francesco,

    you could do:

     sscanf(temp, "%d/%d/%d %d:%d:%d", &month, &day, &year, &h, &m, &s);
     TDatime day_hour(year, month, day, h, m, s);

Cheers, Fons.

On 28/11/2011 13:35, perfetto_at_na.infn.it wrote:
> Hello All,
>
> I have the following problem: I read from a file a line that I put in a
> variable of type TString, now I would like to convert this variable in a
> TDatime; is this possible ?
>
> Here is some of my code:
> ...
> char temp[100];
> TString time = "time";
> TString * line = new TString(temp);
> if( line->BeginsWith("$DATE") )
> {
> input.getline(temp,256);
> time.ReplaceAll("time",temp);
>
> TDatime day_hour("time");
> ...
>
> When I run the script I have the following error:
>
> Error in<TDatime(sqlDatTime)>: input string not in right format, set to
> current date/time
>
> The line with the date is in the following format:
> 11/18/2011 08:36:49
>
> My ROOT version is 5.30/02 on osx Lion
>
> Is there anyone that can help me ?
>
> Thank in advance
> Francesco.
>
>
>

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers_at_cern.ch              Phone: +41 22 7679248
WWW:    http://fons.rademakers.org           Fax:   +41 22 7669640


Received on Tue Nov 29 2011 - 12:30:01 CET

This archive was generated by hypermail 2.2.0 : Tue Nov 29 2011 - 17:50:02 CET