aboutsummarylogtreecommitdiffstats
path: root/replcallfunc.pas
blob: e7681f629b6b889dcf150234eca6bce47ccdf1cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
unit ReplCallFunc;

{$mode ObjFPC}{$H+}

interface

uses
  Classes, SysUtils;

type
  TReplFuncCaller = class(TObject)
  function ReplaceDateFuncCall(s: String): String;
  function ReplaceTimeFuncCall(s: String): String;
end;

implementation

function TReplFuncCaller.ReplaceDateFuncCall(s: String): String;
var
  CurrentDate: String;
begin
  // Get the current date in the format 'DD.MM.YYYY'
  CurrentDate := FormatDateTime('dd.mm.yyyy', Now);

  // Replace all occurrences of 'GETDATE()' with the current date
  Result := StringReplace(s, 'GETDATE()', CurrentDate, [rfReplaceAll, rfIgnoreCase]);
end;

function TReplFuncCaller.ReplaceTimeFuncCall(s: String): String;
var
  CurrentTime: String;
begin
  // Get the current time in the format 'hh:mm:ss'
  CurrentTime := FormatDateTime('hh:nn:ss', Now);

  // Replace all occurrences of 'GETTIME()' with the current time
  Result := StringReplace(s, 'GETTIME()', CurrentTime, [rfReplaceAll, rfIgnoreCase]);
end;

end.