Topic: Remove date with cwday?
This is an archive from Rails Forum. Check out the new community here!
A forum for Ruby on Rails users
cwday just returns an integer for the day of the week starting on Monday. So if the Date object is today (wednesday) cwday will return 3. You can use this to determine if a given day falls on a weekend:
if Date.today.cwday > 5
# Date is on a weekend
errors.add(:deadline, "can't be on a weekend") if deadline.cwday > 5
Last edited by ryanb (2006-08-16 14:03:39)
Thanks, I think the validation method is my best bet. I appriciate the help.
Hosting provided by aTech Media