On 16.01.2012 20:06, waldo kitty wrote:
with this TLE epoch number, 12013.93338171, ya feed it like so...

var
JEpoch : double;
DT : TDateTime;

[...]
JEpoch := getJulianDay_SatEpoch(12,013.93338171);
[...]
if TryJulianDateToDateTime(JEpoch,DT) then
writeln(FormatDateTime('YYYY MM DD hh:mm:ss',DT));


the above /should/ return 2012 01 14 22:24:04... i'm getting the right
dates back but all of the times are 00:00:00 :(

do JulianDateToDateTime and TryJulianDateToDateTime not do anything with
hours, minutes, seconds and milliseconds??

A quick look at the code reveiled that it doesn't handle it. But at least that one should be the same as the one TDateTime uses, so you might try the following (which you can then pack into a function yourself):

var
  JEpoch: Double;
  DT: TDateTime;
begin
  JEpoch := getJulianDay_SatEpoch(12,013.9338171);
  if TryJulianDateToDateTime(JEpoch, DT) then begin
DT := DT + Frac(JEpoch); // the time part should be the one after the comma in both Julian and DateTime models Writeln(FormatDateTime('YYYY MM DD hh:nn:ss', DT)); // you need to use "nn" for minutes as listed here: http://www.freepascal.org/docs-html/rtl/sysutils/formatchars.html
  end;
end;


i'd give TryModifiedJulianDateToDateTime a try but the docs state that
just trying to use that routine raises an exception... is it going to
handle the hors, minutes, seconds, and milliseconds when it gets done or
is it for some other julian date format??

The three "Modified Julian Date" functions are implemented as follows, so there should be no exception if you use the TryModifiedJulianDateToDateTime function (this seems to be another documentation error then):

Function DateTimeToModifiedJulianDate(const AValue: TDateTime): Double;
begin
  result := DateTimeToJulianDate(AValue) - 2400000.5;
end;


Function ModifiedJulianDateToDateTime(const AValue: Double): TDateTime;
begin
  result := JulianDateToDateTime(AValue + 2400000.5);
end;


Function TryModifiedJulianDateToDateTime(const AValue: Double; out ADateTime: TDateTime): Boolean;
begin
  Result:=TryJulianDateToDateTime(AValue + 2400000.5, ADateTime);
end;


[ aside: where/how does one report documentation errors? PadLeft says to
see also PadLeft instead of PadRight ;) ]

You can report all documentation errors at http://bugs.freepascal.org as well. Just select as Category "Documentation".

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to