Validating a date is a Monday

I’m trying to do this…

def validate

 errors.add_to_base "requested start date must be a monday" if

requested_start_date != Chronic.parse(‘monday’)

end

Not working though - this fails vaildation all the time (regardless of
whether the date is a monday or not)

What am I missing here ?

thanks

bb

On Apr 10, 7:26 am, bingo bob [email protected]
wrote:

whether the date is a monday or not)

Chronic.parse(‘monday’) returns a particular monday (looks like next
monday), what else could it do. As a result your code doesn’t check
that the day of week is monday, it checks whether it is a particular
monday at a particular time. You should look at the wday method on
Time/Date, which returns the day of week.

Fred

I have Chronic in place - can it help me work out if the date is a
Monday?

YOU GOT IT :-)… Thanks Fred (again)… easy, no need for chronic…

this seems to work

 errors.add_to_base "requested start date must be a monday" if 

requested_start_date.wday != 1

1 being Monday

bb.