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 2009-04-10 10:26
on 2009-04-10 11:31
On Apr 10, 7:26 am, bingo bob <firstname.lastname@example.org> 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
on 2009-04-10 11:33
I have Chronic in place - can it help me work out if the date is a Monday?
on 2009-04-10 11:40
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.