Skip to content

Commit

Permalink
Document next_business_day and previous_business_day
Browse files Browse the repository at this point in the history
  • Loading branch information
Darhazer authored Mar 29, 2024
1 parent d84e3d0 commit b23df11
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ calendar.subtract_business_days(date, 4).strftime("%A, %d %B %Y")
# => "Friday, 06 June 2014"
```

For getting the next or previous business day, instead of passing `1` to `add_business_days` or `subtract_business_days`, `next_business_day` and `previous_business_day` could be used respectively:

```ruby
date = Date.parse("Friday, 13 June 2014")
calendar.next_business_day(date).strftime("%A, %d %B %Y")
# => "Monday, 16 June 2014"
calendar.previous_business_day(date).strftime("%A, %d %B %Y")
# => "Thursday, 12 June 2014"
```

The `roll_forward` and `roll_backward` methods snap a date to a nearby business day. If provided with a business day, they will return that date. Otherwise, they will advance (forward for `roll_forward` and backward for `roll_backward`) until a business day is found.

```ruby
Expand Down

0 comments on commit b23df11

Please sign in to comment.