<p>Am 16.01.2012 04:10 schrieb "waldo kitty" <<a href="mailto:wkitty42@windstream.net">wkitty42@windstream.net</a>>:<br>
><br>
><br>
> i'm needing to convert a "UTC epoch" date to a "standard time string"... by that, i mean that i want to get something like "2011-01-13 22:24:04" out of the "epoch" number 12013.9338171...<br>

><br>
> the above "epoch" number is (supposedly) built like this...<br>
><br>
> 12 == 2012<br>
> 013 == 13th day of the year<br>
> .9338171 * 24 == 22.4116104 hours<br>
> .4114104 * 60 == 24.696624 minutes<br>
><br>
> and here's where it breaks on me because<br>
><br>
> .696624 * 60 == 41.79744 seconds and that doesn't match the above time string showing 04 seconds... that time string was built from this "epoch" number (by another program) and i assume that it followed this published formula for this format (which is for satellite TLEs)...<br>

><br>
> so, my question is this... is there an existing FPC routine that will convert this (or a part of this) properly or do i need to play with something to get it right? it is obvious that this is not a "unix epoch"... i'm not sure how "normal" julian date epochs are represented...<br>

><br>
> i've looked through the docs on <a href="http://freepascal.org">freepascal.org</a> but none of them show an number with which to compare... there's no links pointing to a definition or example of a julian date or unix date or any such...</p>

<p>I don't know whether your format is really a Julian or Unix time (for Julian it looks too low), but can take a look at unit "DateUtils" of which the documentation is here: <a href="http://www.freepascal.org/docs-html/rtl/dateutils/index-5.html">http://www.freepascal.org/docs-html/rtl/dateutils/index-5.html</a><br>

Especially you can try JulianToDateTime and UnixToDateTime. Both return a TDateTime which you can convert to a string using FormatDateTime ( <a href="http://www.freepascal.org/docs-html/rtl/sysutils/datetimetostring.html">http://www.freepascal.org/docs-html/rtl/sysutils/datetimetostring.html</a> ) or DateTimeToStr ( <a href="http://www.freepascal.org/docs-html/rtl/sysutils/datetimetostr.html">http://www.freepascal.org/docs-html/rtl/sysutils/datetimetostr.html</a>).</p>

<p>Regards,<br>
Sven</p>