Skip to content

Commit

Permalink
Fix default DateTime stringification for second 0..^1
Browse files Browse the repository at this point in the history
Spotted by Stefan Seifert++.
  • Loading branch information
lizmat committed Mar 11, 2020
1 parent 33fc895 commit 95de785
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core.c/DateTime.pm6
Expand Up @@ -51,7 +51,7 @@ my class DateTime does Dateish {
$second
));
}
else {
elsif $second {
my int $int = ($!second * 1000000 + .5).Int;
my int $whole = nqp::substr($int,0,nqp::chars($int) - 6);
nqp::push_s($parts,nqp::concat(
Expand All @@ -61,6 +61,14 @@ my class DateTime does Dateish {
nqp::push_s($parts,'.');
nqp::push_s($parts,nqp::substr($int,nqp::chars($int) - 6));
}
else {
my int $int = ($!second * 1000000 + .5).Int;
nqp::push_s($parts,'00.');
nqp::push_s($parts,nqp::concat(
nqp::x('0',6 - nqp::chars($int)),
$int
));
}

if nqp::getattr_i(self,DateTime,'$!timezone') -> int $tz {
nqp::push_s($parts,nqp::islt_i($tz,0) ?? '-' !! '+');
Expand Down

0 comments on commit 95de785

Please sign in to comment.