Is there a way in Ruby to calculate the number of weeks(ISO 8601) for a given year? I'm currently using a lookup table and I'd like to stop using it.
def num_weeks(year = Date.today.year) Date.new(year, 12, 28).cweek # magick date! end long_iso_years = (2000..2400).select{|year| num_weeks(year) == 53}
Yields the same list as wikipedia
2.1m questions
2.1m answers
60 comments
57.0k users