.NET 中是否有采用 DateTime 参数的方法或函数 Frac 的替代方法?
我正在使用 Delphi Prism for .NET。我需要能够获取日期时间值并将时间与日期分开。我可以在 Win32 Delphi 上使用 Frac 函数来做到这一点。我似乎找不到任何与 .NET 类似的东西。你知道是否存在这样的东西吗?
运气不太好,我为 .NET 编写了自己的 Frac 方法,但它只希望运行 Double 或 Decimal 值,而不运行 DateTime。 .NET 似乎并不将 DateTime 值视为浮点型或小数型。这是真的吗?如果这是真的,我的 Frac 方法就行不通了。
method Frac(theValue:Double):Double;
begin
result := (theValue-math.Truncate(theValue));
end;
我将日期时间选择器设置为时间格式并检索值并将其设置为日期时间变量,但只想要时间而不是日期。
感谢您的帮助。
I am working with Delphi Prism for .NET. I need to be able to take DateTime Value and separate the time from the date. I can do that on Win32 Delphi by using Frac function. I can't seem to find anything similar to that for .NET. Do you know if anything exists for that?
Having not much luck, I wrote my own Frac method for .NET, but it only wants Double or Decimal values to run not DateTime. It seems .NET doesn't treat DateTime Value as a Float or Decimal. Is that true? If that is true, my Frac method won't work.
method Frac(theValue:Double):Double;
begin
result := (theValue-math.Truncate(theValue));
end;
I have the datetimepicker set to Time format and retrieve the value and set it a datetime variable but only want the time not the date.
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DateTime.Date
和DateTime.TimeOfDay
?(事实上,答案是是的,有< em>DateTime 有很多错误,但那是另一回事......当然,如果您有兴趣使用 Noda Time,我非常有兴趣收到您的来信...)
Anything wrong with
DateTime.Date
andDateTime.TimeOfDay
?(In fact, the answer is yes, there is quite a lot wrong with
DateTime
, but that's a different matter... of course if you're interested in using Noda Time from Delphi, I'd be very interested in hearing from you...)