Skip to content

Commit 72a5d92

Browse files
committed
Document infix:<-> and infix:<+> for Date
1 parent 1ba632e commit 72a5d92

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

doc/Type/Date.pod6

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,29 @@ my $instant = DateTime.new(
312312
sleep-until $instant;
313313
qqx{mplayer wake-me-up.mp3};
314314
315+
=head2 sub infix:<->
316+
317+
sub infix:<-> (Date:D, Int:D --> Date:D)
318+
sub infix:<-> (Date:D, Date:D --> Int:D)
319+
320+
Takes a date to subtract from and either an L«C<Int>|/type/Int», representing
321+
the number of days to subtract, or another L«C<Date>|/type/Date» object.
322+
Returns a new L«C<Date>|/type/Date» object or the number of days between the
323+
two dates, respectively.
324+
325+
say Date.new('2016-12-25') - Date.new('2016-12-24') # 1
326+
say Date.new('2015-12-25') - Date.new('2016-11-21') # -332
327+
say Date.new('2016-11-21') - 332 # 2015-12-25
328+
329+
=head2 sub infix:<+>
330+
331+
sub infix:<+> (Date:D, Int:D --> Date:D)
332+
sub infix:<+> (Int:D, Date:D --> Date:D)
333+
334+
Takes an L«C<Int>|/type/Int» and adds that many days to the given
335+
L«C<Date>|/type/Date» object.
336+
337+
say Date.new('2015-12-25') + 332 # 2016-11-21
338+
say 1 + Date.new('2015-12-25') # 2015-12-26
339+
315340
=end pod

0 commit comments

Comments
 (0)