Date.add_work_days
Group: DateTime
Documentation
Shift the date by the specified amount of business days. For the purpose of this method, the business days are defined to be Monday through Friday. Produces a warning for a Date that is before epoch start. See Date_Time.enso_epoch_start
. This method always returns a day which is a business day - if the shift amount is zero, the closest following business day is returned. For the purpose of calculating the shift, the holidays are treated as if we were starting at the next business day after them, for example counting the shift starting on Saturday or Sunday works as if we were counting the shift from Monday (for positive shifts). So shifting Sunday by zero days will return Monday, but shifting it by one day will return a Tuesday (so that there is the full work day - Monday) within the interval. For negative shifts, shifting either Saturday or Sunday one day backwards will return Friday, but shifting Monday one day backwards will return a Friday. The whole logic is made consistent with work_days_until
, so that the following properties hold: date.work_days_until (date.add_work_days N) == N for any N >= 0 (date.add_work_days N).work_days_until date == -N for any N < 0
Arguments
amount
: The number of business days to shift the date by. Ifamount
is zero, the current date is returned, unless it is a weekend or a holiday, in which case the next business day is returned.holidays
: An optional list of dates of custom holidays that should also be skipped. If it is not provided, only weekends are skipped.
Examples
Shift the date by 5 business days.
example_shift = Date.new 2020 2 3 . add_work_days 5