Documentation for sub infix:<->
assembled from the following pages:
Class: Date §
From Date
(Date) sub infix:<-> §
multi sub infix:<-> (Date, Int --> Date)multi sub infix:<-> (Date, Date --> Int)
Takes a date to subtract from and either an Int
, representing the number of days to subtract, or another Date
object. Returns a new Date
object or the number of days between the two dates, respectively.
say Date.new('2016-12-25') - Date.new('2016-12-24'); # OUTPUT: «1» say Date.new('2015-12-25') - Date.new('2016-11-21'); # OUTPUT: «-332» say Date.new('2016-11-21') - 332; # OUTPUT: «2015-12-25»
Class: DateTime §
From DateTime
(DateTime) sub infix:<-> §
multi sub infix:<-> (DateTime, Duration --> DateTime)multi sub infix:<-> (DateTime, DateTime --> Duration)
Takes a DateTime
to subtract from and either a Duration
or another DateTime
object. Returns a new DateTime
object or the Duration
between the two dates, respectively. When subtracting Duration
, time zone of the original DateTime
is preserved in the returned DateTime
object.
say raku DateTime.new(:2016year) - DateTime.new(:2015year):;# OUTPUT: «Duration.new(31536001.0)» say DateTime.new(:2016year, :3600timezone) - Duration.new(31536001.0);# OUTPUT: «2015-01-01T00:00:00+01:00»
Class: Range §
From Range
(Range) sub infix:<-> §
multi sub infix:<->(Range \r, Real \v)
Takes an Real
and subtract that number to both boundaries of the Range object. Be careful with the use of parenthesis.
say (1..2) - 1; # OUTPUT: «0..1» say 1..2 - 1; # OUTPUT: «1..1»