瀏覽代碼

* Add format method for Delphi compatibility

Michaël Van Canneyt 3 周之前
父節點
當前提交
64e57de183
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      packages/rtl-objpas/src/inc/dateutil.inc

+ 7 - 0
packages/rtl-objpas/src/inc/dateutil.inc

@@ -541,6 +541,7 @@ type
     property UnixTime: Int64 read GetUnixTime;
     property TotalSeconds: Int64 read GetTotalSecounds;
     function ToString(const aFormatStr: string = ''): string; inline;
+    function Format(const aFormatStr: string) : string;
     function StartOfYear: TDateTime; inline;
     function EndOfYear: TDateTime; inline;
     function StartOfMonth: TDateTime; inline;
@@ -3490,6 +3491,12 @@ begin
   Result := StartOfTheYear(Self);
 end;
 
+function TDateTimeHelper.Format(const aFormatStr: string) : string;
+
+begin
+  Result:=FormatDateTime(aFormatStr, Self);
+end;
+
 function TDateTimeHelper.ToString(const aFormatStr: string): string;
 begin
   if aFormatStr = '' then