Skip to main content

Date_Range.with_step

with_stepnew_step

Group: Calculations

Documentation

Creates a copy of this range with a changed step.

Arguments

  • new_step: The new step to use. It can either be a Date_Period or Period. The provided Period must be positive, i.e. all of years, months and days must be non-negative and at least one of them has to be positive.

Examples

Create a range representing the first day of every month in a year.

      (Date.new 2020 1 1).up_to (Date.new 2020 12 31) . with_step Date_Period.Month

Create a a decreasing range of every other day between two dates.

      (Date.new 2022 10 23).down_to (Date.new 2022 10 1) . with_step (Period.new days=2)