TDatime and AM/PM time format

Hello, I have a data file with the follwoing informations:
01/01/2008 12:52:01 AM 40.204100
01/01/2008 01:52:01 AM 40.203900
01/01/2008 02:52:01 AM 40.203700
01/01/2008 03:52:01 AM 40.203600

The last column is the weight of my sample. I’d like to plot the weight w.r.t. time, using the time format axis. this is my piece of code (please, see below). It works, but I need to consider if the time is AM or PM. Any idea?
Thanks a lot
Davide Perego

[code]ifstream in_file;
TString dateStr1; // Date (mm/dd/yyyy)
TString dateStr2; // Date (hh:mm:ss)
Char_t Date_3[2]; // AM/PM
Double_t Mass[num_data]; // Elapsed time (min)

// Time offset
TDatime T0(2008,01,01,0,00,00);
Int_t X0 = T0.Convert();
for (Int_t i=0; i<num_data; i++) {
in_file >>dateStr1 >>dateStr2 >>Date_3 >>Mass[i];

// Date-time transformation
const TPRegexp r1("(\d{2})/(\d{2})/(\d{4})");
const TPRegexp r2("(\d{2}):(\d{2}):(\d{2})");
const TObjArray *subStrL1 = r1.MatchS(dateStr1);
const TObjArray *subStrL2 = r2.MatchS(dateStr2);

if (subStrL1->GetLast()+1 >= 3) {
const Int_t month = ((TObjString *)subStrL1->At(1))->GetString().Atoi();
const Int_t day = ((TObjString *)subStrL1->At(2))->GetString().Atoi();
const Int_t year = ((TObjString *)subStrL1->At(3))->GetString().Atoi();
const Int_t hour = ((TObjString *)subStrL2->At(1))->GetString().Atoi();
const Int_t min = ((TObjString *)subStrL2->At(2))->GetString().Atoi();
const Int_t sec = ((TObjString *)subStrL2->At(3))->GetString().Atoi();
TDatime t(year,month,day,hour,min,sec);
X2[i] = t.Convert(1)-X0;
delete subStrL1;
delete subStrL2;

You can do:

h->GetXaxis()->SetTimeFormat(Form("%H %s",ampm));

where “ampm” is a character string containing “AM” or “PM” depending what you read in the file.