瀏覽代碼

bypass `real` → `integer` conversion → `real` promotion in `dateUtils.dateOf`

The `dateUtils.dateOf` function takes one `tDateTime` value, a `real` value,
converts it to an `integer` using `trunc`, and then the value is automatically
promoted to a `real` value again (because of result data type `tDateTime`).

This is unnecessary (unless an error is the desired behavior).
You can use just `system.int` to obtain the integral (= date) part of `tDateTime`.
Kai Burghardt 2 年之前
父節點
當前提交
5307ef07c4
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      packages/rtl-objpas/src/inc/dateutil.inc

+ 1 - 1
packages/rtl-objpas/src/inc/dateutil.inc

@@ -622,7 +622,7 @@ end;
 
 Function DateOf(const AValue: TDateTime): TDateTime; inline;
 begin
-  Result:=Trunc(AValue);
+  Result:=Int(AValue);
 end;