Skip to content

Commit

Permalink
Streamline R:I.get-local-timezone-offset a bit
Browse files Browse the repository at this point in the history
- 1 scalar alloc less because of binding
- use positional interface to DateTime.new, instead of named

FWIW, it feels to me this should be easier to do, e.g. by looking at the
gmtime and localtime C functions and the difference in their value.
  • Loading branch information
lizmat committed Jan 4, 2019
1 parent 50f0bb2 commit 93b5e2e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/Rakudo/Internals.pm6
Expand Up @@ -825,16 +825,16 @@ implementation detail and has no serviceable parts inside"
#?endif

method get-local-timezone-offset() {
my $utc = time;
my $utc := time;
my Mu $fia := nqp::p6decodelocaltime(nqp::unbox_i($utc));

DateTime.new(
:year(nqp::atpos_i($fia,5)),
:month(nqp::atpos_i($fia,4)),
:day(nqp::atpos_i($fia,3)),
:hour(nqp::atpos_i($fia,2)),
:minute(nqp::atpos_i($fia,1)),
:second(nqp::atpos_i($fia,0)),
nqp::atpos_i($fia,5), # year
nqp::atpos_i($fia,4), # month
nqp::atpos_i($fia,3), # day
nqp::atpos_i($fia,2), # hour
nqp::atpos_i($fia,1), # minute
nqp::atpos_i($fia,0), # second
).posix(True) - $utc;
}

Expand Down

0 comments on commit 93b5e2e

Please sign in to comment.