Hi all,
I'm a bit puzzled by FormatDateTime and EConvertError. According to the docs:
"FormatDateTime formats the date and time encoded in DateTime according to the formatting given in FormatStr. The complete list of formatting characters can be found in formatchars."
and:
"On error (such as an invalid character in the formatting string), and EConvertError exception is raised."
Based on that, I assumed that if FormatStr contained characters not listed in formatchars, and not a literal, then it would raise an exception. Indeed,
try
writeln('Test: '+formatdatetime('a',Now));
except
on E:EConvertError do
writeln(E.Message);
end;
does exactly that. But
try
writeln('Test: '+formatdatetime('b',Now));
except
on E:EConvertError do
writeln(E.Message);
end;
does not. Instead, it prints an upper case B to the console (it's a basic console program). Why does this happen, given that neither a nor b are listed in FormatChars? I was hoping to accept arbitrary format strings as command line parameters, and just pass them directly to FormatDateTime on the assumption that I could catch any invalid character via EConvertError, but it looks like I can't do that. Do I have to parse the user-supplied format strings myself?
TIA,
Rob