DateTimeToJulianDate
The function DateTimeToJulianDate converts a TDateTime value into its corresponding Julian date.
A Julian date (or Julian Day) is a number that refers to the number of days, including fractional days, that have elapsed since a particular historical point in time. The current Julian cycle started at Greenwich noon on January 1, 4713 B.C. (Gregorian calendar), and will end on January 22, 3268 A.D.
Julian date is commonly used by astronomers, geophysicists, and others, and used in computer science to calculate the difference between days, since all numbers in the system are consecutive integers.
For example, the Julian date for December 11, 1942 is 2430705; while December 12, 1942 is 2430706.
Declaration: function DateTimeToJulianDate(const AValue: TDateTime): Double;
Here is an easy example - modify it as required.
procedure
OnMapEvent(
var
Value:Variant);
var
TheDate : TDateTime;
TheJDate :
double
;
begin
//Returns 'The Julian Date of 06-12-2023 00:00:00.000 is 2460284.5'
TheDate := Date;
TheJDate := DateTimeToJulianDate(TheDate);'
LogInfo(
'The Julian Date of '
+FormatDateTime(
'dd-mm-yyyy hh:nn:ss.zzz'
, TheDate)+
' is '
+FloatToStr(TheJDate));
//Returns 'The Julian Date of 06-12-2023 10:22:38.308 is 2460284.93238782'
TheDate := Now;
TheJDate := DateTimeToJulianDate(TheDate);
LogInfo(
'The Julian Date of '
+FormatDateTime(
'dd-mm-yyyy hh:nn:ss.zzz'
, TheDate)+
' is '
+FloatToStr(TheJDate));
end
;
Please also refer to JulianDateToDateTime.
The modified Julian date is the number of days, including fractional days, since Greenwich midnight on November 17, 1858. Modified Julian dates are based on Julian dates, but adjusted to use midnight rather than noon as a starting point, and to use a more recent date as a starting point. Please review DateTimeToModifiedJulianDate for more information.