CFLib.org – Common Function Library Project

GetDateFromJulianDay(JulianDay)

Last updated September 5, 2001

author

Beau A.C. Harbin

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Calculates the date and time from a provided Julian Day value.

Return Values:
Returns a date/time object.

Example:

<CFSET JD = getJulianDay()>
<CFOUTPUT>Today's Julian Day is: #JD# which gives us back today's date: #GetDateFromJulianDay(JD)#</CFOUTPUT>

Parameters:

Name Description Required
JulianDay Value representing the Julian day you want to retrieve the date/time for. Yes

Full UDF Source:

/**
 * Calculates the date and time from a provided Julian Day value.
 * 
 * @param JulianDay 	 Value representing the Julian day you want to retrieve the date/time for. 
 * @return Returns a date/time object. 
 * @author Beau A.C. Harbin (bharbin@figleaf.com) 
 * @version 1.0, September 5, 2001 
 */
function GetDateFromJulianDay(JulianDay){
	var a = 0;
	var b = 0;
	var c = 0;
	var d = 0;
	var e = 0;
	var m = 0;
	var date = 0;
	var JD = JulianDay;
	var time = 0;
	
	a = JD + 32044;
	b = ((4 * a) + 3) \ 146097;
	c = a - (b * 146097) \ 4;
	d = (4 * c + 3) \ 1461;
	e = c - ((1461 * d) \ 4);
	m = (5 * e + 2) \ 153;

	time = TimeFormat(JulianDay, "HH:MM:SS");
	date = DateAdd("h", 12, CreateDateTime(((b * 100) + d - 4800 + (m \ 10)), (m + 3 - (12 * (m \ 10))), ((e - (153 * m + 2) \ 5) + 1), DatePart("h", time), DatePart("n", time), DatePart("s", time)));
	
	return date;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson