开发者

Rails, for each second in past week

开发者 https://www.devze.com 2023-03-30 06:28 出处:网络
I want to do something for each second in the past week and pass in the current epoch time as well... I\'m not sure how to do this, but it seems really trivial, here is my pse开发者_Go百科udo code:

I want to do something for each second in the past week and pass in the current epoch time as well... I'm not sure how to do this, but it seems really trivial, here is my pse开发者_Go百科udo code:

1.week.ago..Time.now do |second|
  puts second
end

How would I make this output the current time in ints for each second in that range?


How about

(1.week.ago.to_i..Time.now.to_i).each{ |second| puts "second=#{second}"}
0

精彩评论

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