/ Published in: Ruby

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# Calculate the number of weekdays between dates workdays = 0 date_has_weekend = false date = self.start_at while date.to_date < finish_at.to_date #If we have a weekend day, increase finish date if date.to_date.wday == 6 or date.to_date.wday == 0 date_has_weekend = true finish_at = finish_at.to_time.advance(:days => 1) end workdays = workdays + 1 unless date.to_date.wday == 0 or date.to_date.wday == 6 date = date.to_time.advance(:days => 1) end
Comments
