in reply to localtime parse within hash init

Re: what would this look like in Perl6...

First of all you wouldn't do this in Perl6 if you could help it! You would just use the built in core DateTime object and then use the attributes on that object to get the bits of the date and time you want >;3 If you grab yourself a copy of Rakudo the following works from the command line REPL:

$ perl6 > my $time = 2014-11-05T22:35:54Z > $time.^methods check-time now clone clone-without-validating Instant posix offset off +set-in-minutes offset-in-hours later earlier truncated-to whole-secon +d in-timezone utc local Date Str IO is-leap-year days-in-month daycou +nt-from-ymd ymd-from-daycount get-daycount day-of-month day-of-week w +eek week-year week-number weekday-of-month day-of-year check-value ch +eck-date truncate-parts new perl gist <anon> <anon> <anon> <anon> <an +on> <anon> <anon> <anon> > $time.^attributes Int $!year Int $!month Int $!day Int $!hour Int $!minute Mu $!second M +u $!timezone Callable &!formatter > say $time.month 11 > above is the current local time as an object. Just time on its own gives you an Int as the system epoch timestamp in seconds. Calling ^methods on anything gives you a list of the methods an object has which is useful for picking up Perl6, ^attributes is similarly useful and makes it fairly obvious what you can get at in DateTime.

Replies are listed 'Best First'.
Re^2: localtime parse within hash init
by Ultimatt (Acolyte) on Nov 05, 2014 at 22:58 UTC