For quite some time, Delphi has allowed custom FormatSettings to be used with many date/time functions. This allows you to use custom date/time settings within an application without changing the Windows options. For example, if you used this code snippet and had a date/time format like mm/dd/yyyy, you would see the date/time reported in the new format instead:
procedure TForm3.Button1Click(Sender: TObject);
var
MySettings: TFormatSettings;
s: string;
d: TDateTime;
begin
GetLocaleFormatSettings(GetUserDefaultLCID, MySettings);
MySettings.DateSeparator := '-';
MySettings.TimeSeparator := ':';
MySettings.ShortDateFormat := 'mm-dd-yyyy';
MySettings.ShortTimeFormat := 'hh:nn:ss';
s := DateTimeToStr(Now, MySettings);
ShowMessage(s);
d := StrToDateTime(s, MySettings);
ShowMessage(DateTimeToStr(d, MySettings));
end;
However, if you used 'mmm-dd-yyyy' as the ShortDateFormat in the example above (to display Jan-09-2006), you would get an error when calling StrToDateTime on this string. The workaround is to call d := VarToDateTime(s) instead, since that function supports month names when encoding the TDateTime. I logged this bug as QC 23301, so if you'd like to see this fixed, please rate this entry and vote on it if it's important enough to you.