Menu

Code Submission

2003-08-19
2003-10-26
  • Ryan J. Mills

    Ryan J. Mills - 2003-08-19

    Here is a function that I couldn't find in your code to convert a TDateTime to TimSeconds:

    function DateTimeToTimSeconds(DateTime:TDateTime):LongWord;
    const
      SecsPerDay = 24 * 60 * 60;
    begin
      if DateTime = 0 then
        Result := 0
      else
        result := ((Trunc(DateTime) - Trunc(EncodeDate(1904, 1, 1))) * SecsPerDay) + Round(frac(DateTime)*SecsPerDay);
    end;

    Thanks for your help.

     
    • Ryan J. Mills

      Ryan J. Mills - 2003-08-19

      Actually it probably needs to be corrected still.

      I noticed, after I posted the code, that if the TDateTime is earlier than 1904 you'll get an incorrect result.

      I'll correct that in my own code.

       
    • Paul Gilbert

      Paul Gilbert - 2003-08-19

      Thanks for the submission. As you point out, it doesn't work properly if the date is before 1904. Wouldn't happen very often.. so it could probably be best guarded against with a simple check and exception if the passed date is earlier than it.

       
    • David Lucchese

      David Lucchese - 2003-10-24

      Hi

      Don't we already have the same tool with the DateTimeToPalmDT function located in pelDateTime unit?

       
      • Paul Gilbert

        Paul Gilbert - 2003-10-26

        Good point. The library has gotten big enough that not even I can remember all of it's functions off the top of my head any more. :)

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.