Skip to content
Permalink
Browse files

Streamline R:I.get-local-timezone-offset a bit

- 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 93b5e2ef2d9d649139ad75efd8d80379528192c4
Showing with 7 additions and 7 deletions.
  1. +7 −7 src/core/Rakudo/Internals.pm6
@@ -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;
}

0 comments on commit 93b5e2e

Please sign in to comment.
You can’t perform that action at this time.