Browse Source

[commons] new simple function helpers

Exilon 3 years ago
parent
commit
6a980510ca
2 changed files with 27 additions and 7 deletions
  1. 23 1
      Quick.Commons.pas
  2. 4 6
      Quick.Crypto.pas

+ 23 - 1
Quick.Commons.pas

@@ -1,4 +1,4 @@
-{ ***************************************************************************
+{ ***************************************************************************
 
   Copyright (c) 2016-2021 Kike P�rez
 
@@ -256,6 +256,16 @@ type
     function IsAM : Boolean;
     function IsPM : Boolean;
   end;
+
+  TDateHelper = record helper for TDate
+  public
+    function ToString : string;
+  end;
+
+  TTimeHelper = record helper for TTime
+  public
+    function ToString : string;
+  end;
   {$ENDIF}
 
   EEnvironmentPath = class(Exception);
@@ -2314,6 +2324,18 @@ function TDateTimeHelper.IsPM : Boolean;
 begin
   Result := System.DateUtils.IsPM(Self);
 end;
+
+{ TDateHelper }
+function TDateHelper.ToString : string;
+begin
+  Result := DateToStr(Self);
+end;
+
+{ TTimeHelper }
+function TTimeHelper.ToString : string;
+begin
+  Result := TimeToStr(Self);
+end;
 {$ENDIF}
 
 {$IFNDEF NEXTGEN}

+ 4 - 6
Quick.Crypto.pas

@@ -30,10 +30,8 @@ unit Quick.Crypto;
 
 interface
 
-uses
-
-function AES128_Encrypt(Value, Password: string): string;
-function AES128_Decrypt(Value, Password: string): string;
+function AES128_Encrypt(const Value, Password: string): string;
+function AES128_Decrypt(const Value, Password: string): string;
 
 implementation
 
@@ -130,7 +128,7 @@ begin
   end;
 end;
 
-function AES128_Encrypt(Value, Password: string): string;
+function AES128_Encrypt(const Value, Password: string): string;
 var
   hCProv: HCRYPTPROV;
   hKey: HCRYPTKEY;
@@ -164,7 +162,7 @@ begin
   end;
 end;
 
-function AES128_Decrypt(Value, Password: string): string;
+function AES128_Decrypt(const Value, Password: string): string;
 var
   hCProv: HCRYPTPROV;
   hKey: HCRYPTKEY;