Fixed date error in POP3 whereas FreePascal wanted dd-mm-yy and BBS provided mm-dd-yy. Software Pop3 client crahed after the 12th day of any given month an failed to send mail.

This commit is contained in:
root 2013-10-13 10:42:20 -07:00
parent 6176f77107
commit b21981f525
1 changed files with 24 additions and 1 deletions

View File

@ -169,8 +169,31 @@ Var
MsgBase : PMsgBaseABS;
Function ParseDateTime (Date, Time : String) : String;
Var
YY, MM, DD : Word;
YYS, MMS, DDS : String;
Code : Word;
myfile : TextFile;
Begin
DateSeparator := '-';
YY := 0;
MM := 0;
DD := 0;
//DateSeparator := '-'; <-- Depreciated
// http://www.freepascal.org/docs-html/rtl/sysutils/strtodatetime.html
// BBS Stores strings as mm-dd-yy but default format for StrtoDateTime is dd-mm-yy.
Val(Copy(Date, 1, 2), MM, Code);
Val(Copy(Date, 4, 2), DD, Code);
Val(Copy(Date, 7, 2), YY, Code);
Str(YY, YYS);
Str(MM, MMS);
Str(DD, DDS);
Date := DDS + '-' + MMS + '-' + YYS;
ParseDateTime := FormatDateTime('ddd, dd mmm yyyy hh:nn:ss', StrToDateTime(Date + ' ' + Time));
End;