-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLMS.Helper.Utils.pas
More file actions
65 lines (51 loc) · 1.31 KB
/
LMS.Helper.Utils.pas
File metadata and controls
65 lines (51 loc) · 1.31 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
unit LMS.Helper.Utils;
interface
function ShadowText(const aText: string): string;
function FormatDateTimeNever(const aDateTime: TDateTime): string;
function FormatDateTimeBlank(const aDateTime: TDateTime): string;
// Property name has underscore so for show purpose better to change it for space
// p.e. Header column "Full name" -> property Full_name
function TextToPropertyName(const aText: string): string;
var
hhide: boolean = true;
implementation
uses
System.SysUtils,
dateutils;
function ShadowText(const aText: string): string;
var
aChar: char;
begin
if hhide then
begin
for var k := 1 to Length(aText) do
begin
if (((k mod 3) = 0) or (((k mod 4) = 0))) then
aChar := '*'
else
aChar := aText[k];
result := result + aChar;
end
end
else
result := aText;
end;
function FormatDateTimeBlank(const aDateTime: TDateTime): string;
begin
if datetimetounix(aDateTime) > 0 then
result := DateTimeToStr(aDateTime)
else
result := '';
end;
function FormatDateTimeNever(const aDateTime: TDateTime): string;
begin
if datetimetounix(aDateTime) = 0 then
result := 'never'
else
result := DateTimeToStr(aDateTime);
end;
function TextToPropertyName(const aText: string): string;
begin
result := StringReplace(aText, ' ', '_', [rfReplaceAll]);
end;
end.