[fpc-pascal] Date conversion question

esby at free.Fr esby at free.Fr
Fri Jun 6 10:38:28 CEST 2008


Hello,
I have a little project in which I need to convert various string 
encoded in various date format to TDateTime.
For the same date, I'll have:

'2008-05-10 21:49:21'
'2008:05:10 21:49:21'
'2008-05-10T19:49:21Z'

I am no expert with date manipulation so I am asking:

For the first type of string;
 DateSeparator:= '-';
 ShortDateFormat:= 'yyyy:MM:dd';
 StrToDateTime(str_date); //gets converted.

For the second type of string;
 ShortDateFormat:= 'yyyy:MM:dd';
 DateSeparator:= ':';
 StrToDateTime(str_date); // will trigger an exception
Is that intented or normal? Is there a method available except replacing 
the ':' by '-' in the date part?

For the third type of string;
Should I convert the third string and remove the T and Z chars or are 
there any others methods available?

Thanks in advance.






More information about the fpc-pascal mailing list