Date truncated-to method argument?
http://doc.perl6.org/type/Date says my $c = Date.new('2012-12-24'); say $c.truncated-to(:year); # 2012-01-01 but this doesn't work and what's implemented appears to be year rather than :year $ perl6 my $c = Date.new('2012-12-24'); 2012-12-24 say $c.truncated-to(year) 2012-01-01 Which is correct the code or docs? -- 4096R/EA75174B Steve Mynott steve.myn...@gmail.com
Re: Date truncated-to method argument?
Hi, On 11/10/2014 01:39 PM, Steve Mynott wrote: http://doc.perl6.org/type/Date says my $c = Date.new('2012-12-24'); say $c.truncated-to(:year); # 2012-01-01 but this doesn't work and what's implemented appears to be year rather than :year $ perl6 my $c = Date.new('2012-12-24'); 2012-12-24 say $c.truncated-to(year) 2012-01-01 Which is correct the code or docs? iirc there was a spec change. Let's check... $ ~/p6/specs (master)$ git log -p -S truncated commit 9d8bc5fe62dd38805d791c0351c85185d351290e Author: Carl Masak cma...@gmail.com Date: Thu Jan 24 18:27:55 2013 +0100 [S32/Temporal] spec DateTime.delta and Date.delta Clarify the .truncated-to method as well; it also uses the CTimeUnit enum, instead of named parameters. ... -The Ctruncated-to method allows you to clear a number of time values +The Ctruncated-to constructor allows you to clear a number of time values below a given resolution: my $dt = DateTime.new('2005-02-01T15:20:35Z'); -say $dt.truncated-to(:hour); # 2005-02-01T15:00:00Z +say $dt.truncated-to(hour); # 2005-02-01T15:00:00Z -An argument of C:week yields an object with the date of the last Monday +Arguments to Ctruncated-to belong to the enum CTimeUnit, which encompasses +these values: + +second seconds +minute minutes +hourhours +day days +weekweeks +month months +yearyears + ... so looks like the docs are out of date. Patches to fix that would be awesome! Cheers, Moritz
Re: Date truncated-to method argument?
Moritz (): iirc there was a spec change. Let's check... $ ~/p6/specs (master)$ git log -p -S truncated commit 9d8bc5fe62dd38805d791c0351c85185d351290e Author: Carl Masak cma...@gmail.com Date: Thu Jan 24 18:27:55 2013 +0100 [S32/Temporal] spec DateTime.delta and Date.delta Clarify the .truncated-to method as well; it also uses the CTimeUnit enum, instead of named parameters. But that spec change has since been superseded by a newer, much better one: $ git show 337f4 commit 337f433398a070884e3258fc724c3b5f775fe085 Author: Carl Masak cma...@gmail.com Date: Sat May 10 20:34:03 2014 +0200 [S32/Temporal] retire TimeUnit enum and .delta Use strings in .truncate-to instead. .delta now becomes .later and .earlier, and they expect string keys as named arguments. [...] my $dt = DateTime.new('2005-02-01T15:20:35Z'); -say $dt.truncated-to(hour); # 2005-02-01T15:00:00Z +say $dt.truncated-to('hour'); # 2005-02-01T15:00:00Z [...] -The Cdelta constructor allows you to move a number of CTimeUnits forward or -backward in time. +The Clater and Cearlier constructors allows you to move a number of time +units forward or backward in time. -$dt.delta(44, minutes); -$dt.delta(-1, week); +$dt.later(minutes = 44); +$dt.earlier(week = 1); + +(Both Clater and Cearlier accept zero or negative integers, with the obvious +extended semantics.) [...] (end of diff) ...and that's how .truncated-to got its string argument. The end. // Carl
[perl #111572] [BUG] Unicode problem with 2012.0 on Mac OSX 10.7.3
With the latest parrot the tests in S19-command-line/dash-e.t pass on Mac OS X. I unfudged the tests with commit https://github.com/perl6/roast/commit/5d89b2877e and I'm closing this ticket now.
[perl #123168] [BUG] Statement-modifying if falsely detected as p5-idiomatic /i after assigning form of regex substitution in Rakudo
# New Ticket Created by Carl Mäsak # Please include the string: [perl #123168] # in the subject line of all future correspondence about this issue. # URL: https://rt.perl.org/Ticket/Display.html?id=123168 FROGGS hmmm, I've seen that before somewhere: FROGGS ===SORRY!=== Error while compiling lib/Cache/Memcached.pm FROGGS Unsupported use of /i; in Perl 6 please use :i FROGGS at lib/Cache/Memcached.pm:479 FROGGS -- $ip ~~ s:g [ \[ | \] ] = '' i⏏f $ip.defined; FROGGS m: my $foo = ; $foo ~~ s:g [ \[ | \] ] = '' if $foo.defined camelia rakudo-moar cb1b1c: OUTPUT«===SORRY!=== Error while compiling /tmp/3RGHPjSBidUnsupported use of /i; in Perl 6 please use :iat /tmp/3RGHPjSBid:1-- foo = ; $foo ~~ s:g [ \[ | \] ] = '' i⏏f $foo.defined» FROGGS std: my $foo = ; $foo ~~ s:g [ \[ | \] ] = '' if $foo.defined camelia std : OUTPUT«Can't chdir to [...] FROGGS hmpf PerlJam FROGGS: maybe change old_rx_mods to look for a word boundary after the character class since it's comparing against single characters anyway. PerlJam (Is it a bug that we don't look for repeated modifiers?) masak FROGGS: ooh -- can I rakubmit that one? FROGGS masak: surely :o) * masak does