In Range§
See primary documentation in context for sub infix:<+>.
multi infix:<+>(Range:D \r, Real:D \v) multi infix:<+>(Real:D \v, Range:D \r)
Takes a Real
and adds that number to both boundaries of the Range
object. Be careful with the use of parenthesis.
say (1..2) + 2; # OUTPUT: «3..4» say 1..2 + 2; # OUTPUT: «1..4»
In Date§
See primary documentation in context for sub infix:<+>.
multi infix:<+> (Date:D, Int:D --> Date:D) multi infix:<+> (Int:D, Date:D --> Date:D)
Takes an Int
and adds that many days to the given Date
object.
say Date.new('2015-12-25') + 332; # OUTPUT: «2016-11-21» say 1 + Date.new('2015-12-25'); # OUTPUT: «2015-12-26»
In DateTime§
See primary documentation in context for sub infix:<+>.
multi infix:<+> (DateTime:D, Duration:D --> DateTime:D) multi infix:<+> (Duration:D, DateTime:D --> DateTime:D)
Takes a DateTime
and increases it by the given Duration
, preserving the time zone.
say DateTime.new(:2015year) + Duration.new(31536001.0); # OUTPUT: «2016-01-01T00:00:00Z» say Duration.new(42) + DateTime.new(:2015year, :3600timezone); # OUTPUT: «2015-01-01T00:00:42+01:00»