In Range§
See primary documentation in context for sub infix:<->
multi infix:<->(Range \r, Real \v)
Takes a 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»
In DateTime§
See primary documentation in context for sub infix:<->
multi infix:<-> (DateTime, Duration --> DateTime)multi 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»
In Date§
See primary documentation in context for sub infix:<->
multi infix:<-> (Date, Int --> Date)multi 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»