Date truncated-to method argument?

2014-11-10 Thread Steve Mynott
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?

2014-11-10 Thread Moritz Lenz

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