Run the following command-line program:
Program StrToDateBug;
uses SysUtils;
Const
FullDateFormat = 'dddddd';
var
S : String;
D : TDate;
Res : Boolean;
Begin
D := Now;
S := FormatDateTime(FullDateFormat,D);
Writeln('Date of today is ' , S);
Res := TryStrToDate(S,D,FullDateFormat);
If Res
then Writeln('Date is valid')
else Writeln('Date is invalid');
Readln;
End.
Even though
S is assigned the valid date from
FormatDateTime,
TryStrToDate returns an invalid response. I tracked the bug to the function
IntStrToDate: It doesn't consider the case where the format is six 'd's (dddddd).
If it's a bug, I'd be happy to rewrite this routine, unless it was not meant to handle this format...