开发者

Rails 3 week display

开发者 https://www.devze.com 2023-03-03 03:56 出处:网络
How Can i display the remai开发者_StackOverflow中文版ning weeks of the year in rails?You don\'t really specify a format here obviously, but something like this will show you the index of every week le

How Can i display the remai开发者_StackOverflow中文版ning weeks of the year in rails?


You don't really specify a format here obviously, but something like this will show you the index of every week left in the year:

(Date.today.cweek..52).each { |w| puts w }

See Looping through weeks of the year in Ruby (Sinatra) for a similar question


(Date.today.cweek...Date.today.end_of_year.cweek)

EDIT

(Date.today.cweek...Date.today.end_of_year.cweek).each_slice(2) do |weeks|
  puts weeks.join("-")
end
0

精彩评论

暂无评论...
验证码 换一张
取 消