From 80b7d40a77ae84178ac0d5bad1eaf8947f6d4a49 Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Sat, 25 May 2013 13:56:11 -0400 Subject: [PATCH] Format date function --- mdl/m_datetime.pas | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mdl/m_datetime.pas b/mdl/m_datetime.pas index ae62774..e7d4674 100644 --- a/mdl/m_datetime.pas +++ b/mdl/m_datetime.pas @@ -30,6 +30,7 @@ Function TimeDos2Str (Date: LongInt; Mode: Byte) : String; Function DayOfWeek (Date: LongInt) : Byte; Function DaysAgo (Date: LongInt; dType: Byte) : LongInt; Function TimeSecToStr (Secs: LongInt) : String; +Function FormatDate (DT: DateTime; Mask: String) : String; Implementation @@ -355,4 +356,20 @@ Begin Result := (Temp - Secs) >= 0; End; +Function FormatDate (DT: DateTime; Mask: String) : String; +Var + YearStr : String[4]; +Begin + Result := Mask; + YearStr := strI2S(DT.Year); + Result := strReplace(Result, 'YYYY', YearStr); + Result := strReplace(Result, 'YY', Copy(YearStr, 3, 2)); + Result := strReplace(Result, 'MM', strZero(DT.Month)) + + strReplace(Result, 'DD', strZero(DT.Day)) + + strReplace(Result, 'HH', strZero(DT.Hour)) + + strReplace(Result, 'II', strZero(DT.Min)) + + strReplace(Result, 'SS', strZero(DT.Sec)) + + strReplace(Result, 'NNN', MonthString[DT.Month]); +End; + End.