File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -312,4 +312,29 @@ my $instant = DateTime.new(
312
312
sleep-until $instant;
313
313
qqx{mplayer wake-me-up.mp3};
314
314
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
+
315
340
= end pod
You can’t perform that action at this time.
0 commit comments