Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to convert from DateTime to RFC822 date Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Aug-03
Category
Algorithm
Language
Delphi 5.x
Views
154
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Christian Cristofori

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? 

Answer:
1   
2   function DateTimeToRFC822(DTTime: TDateTime): string;
3   var
4     IdX: Integer;
5     SaveShortDayNames: array[1..7] of string;
6     SaveShortMonthNames: array[1..12] of string;
7   const
8     MyShortDayNames: array[1..7] of string = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 
9   'Fri',
10      'Sat');
11    MyShortMonthNames: array[1..12] of string = ('Jan', 'Feb', 'Mar', 'Apr', 'May',
12      'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
13  begin
14    if (ShortDayNames[1] = MyShortDayNames[1]) then
15      Result := FormatDateTime('ddd, d mmm yyyy hh:mm:ss', DTTime)
16    else
17    begin
18      for IdX := Low(ShortDayNames) to High(ShortDayNames) do
19      begin
20        SaveShortDayNames[IdX] := ShortDayNames[IdX];
21        ShortDayNames[IdX] := MyShortDayNames[IdX];
22      end;
23      for IdX := Low(ShortMonthNames) to High(ShortMonthNames) do
24      begin
25        SaveShortMonthNames[IdX] := ShortMonthNames[IdX];
26        ShortMonthNames[IdX] := MyShortMonthNames[IdX];
27      end;
28      Result := FormatDateTime('ddd, d mmm yyyy hh:mm:ss', DTTime);
29      for IdX := Low(ShortDayNames) to High(ShortDayNames) do
30        ShortDayNames[IdX] := SaveShortDayNames[IdX];
31      for IdX := Low(ShortMonthNames) to High(ShortMonthNames) do
32        ShortMonthNames[IdX] := SaveShortMonthNames[IdX];
33    end;
34  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC