是否有替代.NET中的方法或函数Frac将采用DateTime参数?

时间:2011-10-20 13:07:52

标签: .net math datetimepicker delphi-prism fractions

我正在使用Delphi Prism for .NET。我需要能够获取DateTime值并将时间与日期分开。我可以使用Frac函数在Win32 Delphi上做到这一点。我似乎找不到类似于.NET的东西。你知道是否存在任何东西吗?

运气不好,我为.NET编写了自己的Frac方法,但它只希望Double或Decimal值不运行DateTime。似乎.NET不会将DateTime值视为Float或Decimal。真的吗?如果这是真的,我的Frac方法将不起作用。

method Frac(theValue:Double):Double;
begin
    result := (theValue-math.Truncate(theValue));
end;

我将datetimepicker设置为Time格式并检索该值并将其设置为datetime变量,但只希望时间不是日期。

感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

DateTime.DateDateTime.TimeOfDay有什么不对吗?

(事实上,答案是yes, there is quite a lot wrong with DateTime,但这是另一回事......当然如果你对使用Delphi的Noda Time感兴趣,我会非常感兴趣你...)