Skip to content

Commit

Permalink
Optimize DateTime.day-fraction a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Apr 3, 2021
1 parent 353334f commit 3926026
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core.c/DateTime.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ my class DateTime does Dateish {
}

method day-fraction(DateTime:D: --> Real:D) {
my $sec = self.hour * 60 * 60;
$sec += self.minute * 60;
$sec += self.second;
$sec / (24.0 * 60 * 60)
(nqp::add_i(
nqp::mul_i($!hour,3600),
nqp::mul_i($!minute,60)
) + $!second) / 86400
}

method modified-julian-date(DateTime:D: --> Real:D) {
Expand Down

0 comments on commit 3926026

Please sign in to comment.