Close

The current time in millennia

A project log for How Far is Mars

A project to continually display the distance to every planet

Bill SmithBill Smith 10/04/2015 at 23:560 Comments
sub JulianDate
{
        splice @_, $#_ + 1, 0, 0, 0, 0;
	my( $mo, $day, $yr, $hr, $min, $sec) = @_;

	if( $mo <= 2 ) {
		$yr -= 1;
		$mo += 12;
	}

	# Assumes after 10/4/1582 (Gregorian calendar)
	my $a = int( $yr / 100);
	my $b = 2 - $a + int($a/ 4);
	$day += ((($sec / 60.0 + $min) / 60.0) + $hr) / 24.0;
	return int( 365.25 * ($yr + 4716) + int(30.601 * ($mo + 1))) + $day + $b - 1524.5;
}

The formulas require the date from the year 2000

(JulianDate(....) - 2451545.0) / 365250;

Discussions