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 $d = DateTime.now;
my $sec  = $d.second# Potentially includes fractional seconds 
my $min  = $d.minute;
my $hour = $d.hour;
my $mday = $d.day-of-month# or $d.day; 1..31 
my $mon  = $d.month# 1..12 
my $year = $d.year;
my $wday = $d.day-of-week# 1 => Monday, 2 => Tuesday, etc. 
my $yday = $d.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.