[Lazarus] StrToDate and DefaultFormatSettings
"Leonardo M. Ramé"
l.rame at griensu.com
Fri Sep 12 13:18:36 CEST 2014
Hi, I need to convert strings with format "d-mmm-y" to TDateTime.
For example: '12-Sep-14'
Here's my code:
DefaultFormatSettings.DateSeparator:='-';
DefaultFormatSettings.ShortDateFormat:='D-MMM-Y';
DefaultFormatSettings.ShortMonthNames[1] := 'Jan';
DefaultFormatSettings.ShortMonthNames[2] := 'Feb';
DefaultFormatSettings.ShortMonthNames[3] := 'Mar';
DefaultFormatSettings.ShortMonthNames[4] := 'Apr';
DefaultFormatSettings.ShortMonthNames[5] := 'May';
DefaultFormatSettings.ShortMonthNames[6] := 'Jun';
DefaultFormatSettings.ShortMonthNames[7] := 'Jul';
DefaultFormatSettings.ShortMonthNames[8] := 'Aug';
DefaultFormatSettings.ShortMonthNames[9] := 'Sep';
DefaultFormatSettings.ShortMonthNames[10] := 'Oct';
DefaultFormatSettings.ShortMonthNames[11] := 'Nov';
DefaultFormatSettings.ShortMonthNames[12] := 'Dec';
lStr := DateToStr(now); // This works Ok.
lDate := StrToDate(lStr); // Here I get EConvert exception.
Am I missing something?.
--
Leonardo M. Ramé
http://leonardorame.blogspot.com
More information about the Lazarus
mailing list