sub jd2dt { # convert JD to DateTime my $jd_to_convert = shift; my $days = int $jd_to_convert; # that odd date is "julian day zero", converted to "proleptic" gregorian calendar my $dt = DateTime->new(year => -4713, month => 11, day =>24, hour => 12, time_zone => DateTime::TimeZone->new( name => 'UTC' ))->add(days => $days); $dt->add(hours => 24 * ($jd_to_convert - $days)); return $dt; # 2017-06-13 added this line for clarity }