Главная страница | назад





Article #28419: Web App Debugger incorrectly formats dates based on the current regional settings

The Web App Debugger in Delphi 6 (or 6.01 or 6.02) has a bug in it where it incorrectly formats dates based on the current regional settings. This can hide other bugs which may only appear when you deploy your application to a real web server such as IIS or Apache.

Luckily, the source for the Web App Debugger is included with Delphi 6. Open up the project WebAppDbg.dpr in $(DELPHI)\source\internet. Then, open the file SvrHTTP.pas. On line 678, you will see the start of the procedure TWebServerRequest.SetDateVariable. Modify it as follows:


procedure TWebServerRequest.SetDateVariable(Index: Integer;
Value: TDateTime);
begin
// This previously encoded the date based on the current locale,
// which would hide other bugs if you didn't use the web app debugger.
StringVariable[Index] :=
Format(FormatDateTime('"%s", dd "%s" yyyy hh:mm:ss "GMT"', Value), { do not localize }
[DayOfWeekStr(Value), MonthStr(Value)]);
// StringVariable[Index] := DateTimeToStr(Value) // Old encoding
end;
Compile the application and copy the executable to your $(DELPHI)\bin directory. That should be it! You will now have a patched version of the Web App Debugger.

Last Modified: 20-FEB-02