Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I make sure a day is a weekday in Rails?

I have a message substitution called next_week which basically takes Date.today + 7.days.

However, although I still want to send emails on weekends, if the next_week falls on a weekend, I want it to know this and push to the Monday.

How do i do this?

like image 687
Satchel Avatar asked Oct 04 '10 04:10

Satchel


1 Answers

Rails 5:

date.on_weekend?
date.on_weekday?

Rails 4:

date.saturday? || date.sunday?
like image 142
Marcin Urbanski Avatar answered Oct 14 '22 15:10

Marcin Urbanski