Amos
You have to do the conversion yourself - in my case I do this
HeaderLines.Insert(0, 'Date: ' + Rfc822DateTime(Now));
on sending (Rfc822DateTime is part of Lukas's code)
and
mnd.eMails_Sent.AsDateTime := ConvertToGMT(GetHeaderLine('Date', hdrs, 1024));
on receiving
Roy Lambert
function ConvertToGMT(DateStr: string): TDateTime;
var
ActOn: string;
CurrentBit: string;
Chopper: integer;
Month: Integer;
Day: Integer;
Year: Integer;
Offset: Integer;
Hour: Word;
Minute: Word;
Sec: Word;
DateCreated: boolean;
function GrabNum: integer;
begin
Chopper := 1;
while ActOn[Chopper] in ['0'..'9'] do inc(Chopper);
if Chopper > 1 then Result := StrToInt(Copy(ActOn, 1, Chopper - 1)) else Result
:= 0;
ActOn := Copy(ActOn, Chopper + 1, MaxInt);
end;
procedure GrabMonth;
const
ShortMonths: array[1..12] of string = ('Jan', 'Feb', 'Mar', 'Apr', 'May',
'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
LongMonths: array[1..12] of string = ('January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September', 'October', 'November',
'December');
begin
Chopper := 1;
while ActOn[Chopper] in ['a'..'z', 'A'..'Z'] do inc(Chopper);
CurrentBit := Copy(ActOn, 1, Chopper - 1);
Month := 1;
while (Month < 13) and (not (CurrentBit = ShortMonths[Month])) and (not
(CurrentBit = LongMonths[Month])) do Inc(Month);
ActOn := Copy(ActOn, Chopper + 1, MaxInt);
end;
function GetTimeZone: integer;
const
TimeZones: array[1..28] of string = ('GMT', 'BST', 'IST', 'WEST', 'CET',
'CEST', 'EET', 'EEST', 'MSK', 'MSD', 'AST', 'ADT', 'EST', 'EDT', 'CST', 'CDT',
'MST', 'MDT', 'PST', 'PDT', 'HST', 'AKST', 'AKDT', 'AEST', 'AEDT', 'ACST',
'ACDT', 'AWST');
FromGMT: array[1..28] of real = (0, 1, 1, 1, 1, 2, 2, 3, 3, 4, -4, -3, -5, -4,
-6, -5, -7, -6, -8, -7, -10, -9, -8, 10, 11, 9.3, 10.3, 8);
var
ZoneCntr: integer;
begin
Result := 0;
ZoneCntr := 1;
while (ZoneCntr < High(FromGMT)) and (not (ActOn = TimeZones[ZoneCntr])) do
Inc(ZoneCntr);
if ActOn = TimeZones[ZoneCntr] then Result := Trunc(100 * FromGMT[ZoneCntr]);
end;
begin
ActOn := Trim(DateStr);
if ActOn <> '' then begin
try
if not (ActOn[1] in ['0'..'9']) then ActOn := Copy(ActOn, Pos(' ', ActOn) + 1,
MaxInt);
while ActOn[1] = ' ' do Delete(ActOn, 1, 1);
if (ActOn[1] in ['0'..'9']) then begin
Day := GrabNum;
GrabMonth;
Year := GrabNum;
if Year < 100 then inc(Year, 1900);
Hour := GrabNum;
Minute := GrabNum;
Sec := GrabNum;
DateCreated := False;
try
Result := EncodeDate(Year, Month, Day) + EncodeTime(Hour, Minute, Sec, 0);
DateCreated := True;
if ActOn[Length(ActOn)] in ['0'..'9'] then Offset := StrToInt(ActOn) else
Offset := GetTimeZone;
except
Offset := 0;
if not DateCreated then begin
try
Result := EncodeDate(Year, Month, Day);
except
Result := null;
end;
end;
end;
try
if (Offset <> 0) then begin
if (Offset > 0) then begin
Result := Result - EncodeTime((Offset div 100), (Offset mod 100), 0, 0);
end else begin
Result := Result + EncodeTime((Abs(Offset) div 100), (Abs(Offset) mod 100), 0,
0);
end;
end;
except
end;
end else begin
// Old style date format - should be rare
GrabMonth;
Day := GrabNum;
Hour := GrabNum;
Minute := GrabNum;
Sec := GrabNum;
Year := GrabNum;
if Year < 100 then inc(Year, 1900);
try
Result := EncodeDate(Year, Month, Day) + EncodeTime(Hour, Minute, Sec, 0);
except
try
Result := EncodeDate(Year, Month, Day);
except
Result := null;
end;
end;
end;
except
Result := null;
end;
end else Result := null;
end;
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public