I know there's a method cweek
, which gives me the number of the current week.
However, how do I get the count of weeks for a given year?
I know there's a method cweek
, which gives me the number of the current week.
However, how do I get the count of weeks for a given year?
Maybe with this?
Date.new(2019 , 12, -1).strftime("%U").to_i
if you want the current year could try this
Date.new(Time.now.year , 12, -1).strftime("%U").to_i
Look at the strftime configuration
Week number:
The week 1 of YYYY starts with a Sunday or Monday (according to %U
or %W). The days in the year before the first week are in week 0.
%U - Week number of the year. The week starts with Sunday. (00..53)
%W - Week number of the year. The week starts with Monday. (00..53)