jeudi 23 juin 2016

Nicer way to provide Date Range

I create a date time range like this in rails:

last_3_months = (Date.today - 3.month)..Date.today
next_40_days = Date.today..(Date.today + 40.days)

Is there a nicer way in Ruby to make it more readable? Something like:

last_3_months = 3.months.ago.to_range
next_40_days = 40.days.from_now.to_range

Thanks a lot!

Aucun commentaire:

Enregistrer un commentaire