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
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.