Search code examples
.netmathdatetimepickerdelphi-prismfractions

Is there a replacement for method or function Frac in .NET that will take DateTime parameter?


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.


Solution

  • Anything wrong with DateTime.Date and DateTime.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...)