Given day in week (let's say Monday), I need to find closest date (in future) to given date (for example 9-4-2016) which is this day in week (for these examples, it should be 11-4-2016).
['https://Stackoverflow.com/questions/36534043', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1767332/']
This is a pure Ruby solution.

```
require 'date'

d = Date.strptime('9-4-2016', '%d-%m-%Y')
  #=> #<Date: 2016-04-09 ((2457488j,0s,0n),+0s,2299161j)> 
d + (1 - d.wday) % 7
  #=> #<Date: 2016-04-11 ((2457490j,0s,0n),+0s,2299161j)> 

```

`1` is Monday's offset. `d.wday #=> 6`.

I have assumed that if the date falls on a Monday, the "closest" Monday is the same day. If it is to be the following Monday, use:

```
d + (d.wday == 1) ? 7 : (1 - d.wday) % 7

```
You can find this date in the nearest week of your `date`:

```
date =  Date.parse('9-4-2016')
(date..date + 6).find {|d| d.strftime("%A") == "Monday"}
#=> Mon, 11 Apr 2016

```