Answer the question
In order to leave comments, you need to log in
How to count the number of days off between two dates in Ruby?
Actually the subject, you need to calculate the number of Saturdays and Sundays between two dates
Answer the question
In order to leave comments, you need to log in
Возможно кому-то пригодится, пример
((Date.today - 14)..(Date.today) ).group_by(&:wday)[1].size
Можно написать с помощью изящных руби методов
require 'date'
timerange = Date.parse('2016/01/01')..Date.parse('2016/08/13')
days = 0
timerange.each { |d| days += 1 if d.sunday? or d.saturday? }
# days => 65
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question