Algorithm Math Delphi

Title: How to convert from DateTime to RFC822 date.
Question: I was trying to convert a DateTime value to a RFC822 style date, so I asked to Paolo, a friend of mine, if he did know how it works. He found that on the Net. It's not perfect... someone as a better one?
Thanks.
Answer:
Function DateTimeToRFC822( DTTime : TDateTime ) : String;
Var
IdX : Integer;
SaveShortDayNames : Array[ 1.. 7 ] Of String;
SaveShortMonthNames : Array[ 1..12 ] Of String;
Const
MyShortDayNames : Array[ 1.. 7 ] Of String = ( 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' );
MyShortMonthNames : Array[ 1..12 ] Of String = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
Begin
If ( ShortDayNames[ 1 ] = MyShortDayNames[ 1 ] ) Then
Result := FormatDateTime( 'ddd, d mmm yyyy hh:mm:ss', DTTime )
Else Begin
For IdX := Low( ShortDayNames ) To High( ShortDayNames ) Do Begin
SaveShortDayNames[ IdX ] := ShortDayNames[ IdX ];
ShortDayNames[ IdX ] := MyShortDayNames[ IdX ];
End;
For IdX := Low( ShortMonthNames ) To High( ShortMonthNames ) Do Begin
SaveShortMonthNames[ IdX ] := ShortMonthNames[ IdX ];
ShortMonthNames[ IdX ] := MyShortMonthNames[ IdX ];
End;
Result := FormatDateTime( 'ddd, d mmm yyyy hh:mm:ss', DTTime );
For IdX := Low( ShortDayNames ) To High( ShortDayNames ) Do ShortDayNames[ IdX ] := SaveShortDayNames[ IdX ];
For IdX := Low( ShortMonthNames ) To High( ShortMonthNames ) Do ShortMonthNames[ IdX ] := SaveShortMonthNames[ IdX ];
End;
End;