In Perl to Raku guide - functions§
See primary documentation in context for localtime
localtime EXPR
Most of the functionality of localtime
is found in DateTime
. The specific parts of localtime
can be found as follows:
my = DateTime.now;my = .second; # Potentially includes fractional secondsmy = .minute;my = .hour;my = .day-of-month; # or $d.day; 1..31my = .month; # 1..12my = .year;my = .day-of-week; # 1 => Monday, 2 => Tuesday, etc.my = .day-of-year; # 1..366
Please note that ranges are not 0-based in Raku, as shown in the comments in the example.
There does not currently appear to be a way to get Perl's $isdst
. Also, the result of scalar(localtime)
that Perl provides is not available. $d.Str
will give something along the lines of "2015-06-29T12:49:31-04:00".
The Raku ecosystem has a module P5localtime
which exports a localtime
function that mimics the original Perl behavior as much as possible.