Hello World

Be Happy!

time array in rails


(Time.now.to_i..1.day.from_now.to_i).step(30.minutes).each do |time|
  puts Time.at(time)
end

irb(main):402:0> (Time.now.utc.midnight.ago(1.month).to_i..Time.now.utc.midnight.to_i).step(1.day).each do |time|
irb(main):403:1*     puts Time.at(time)
irb(main):404:1> end
2020-04-01 17:00:00 -0700
2020-04-02 17:00:00 -0700
2020-04-03 17:00:00 -0700
2020-04-04 17:00:00 -0700
2020-04-05 17:00:00 -0700
2020-04-06 17:00:00 -0700
2020-04-07 17:00:00 -0700
2020-04-08 17:00:00 -0700
2020-04-09 17:00:00 -0700
2020-04-10 17:00:00 -0700
2020-04-11 17:00:00 -0700
2020-04-12 17:00:00 -0700
2020-04-13 17:00:00 -0700
2020-04-14 17:00:00 -0700
2020-04-15 17:00:00 -0700
2020-04-16 17:00:00 -0700
2020-04-17 17:00:00 -0700
2020-04-18 17:00:00 -0700
2020-04-19 17:00:00 -0700
2020-04-20 17:00:00 -0700
2020-04-21 17:00:00 -0700
2020-04-22 17:00:00 -0700
2020-04-23 17:00:00 -0700
2020-04-24 17:00:00 -0700
2020-04-25 17:00:00 -0700
2020-04-26 17:00:00 -0700
2020-04-27 17:00:00 -0700
2020-04-28 17:00:00 -0700
2020-04-29 17:00:00 -0700
2020-04-30 17:00:00 -0700
2020-05-01 17:00:00 -0700
=> ((1585785600..1588377600).step(1 day))

irb(main):421:0> (Time.now.utc.midnight.ago(1.month).to_i..Time.now.utc.midnight.to_i).step(1.day).each do |time|
irb(main):422:1*     puts "#{Time.at(time).utc} #{Time.at(time).utc + 1.day}"
irb(main):423:1> end
2020-04-02 00:00:00 UTC 2020-04-03 00:00:00 UTC
2020-04-03 00:00:00 UTC 2020-04-04 00:00:00 UTC
2020-04-04 00:00:00 UTC 2020-04-05 00:00:00 UTC
2020-04-05 00:00:00 UTC 2020-04-06 00:00:00 UTC
2020-04-06 00:00:00 UTC 2020-04-07 00:00:00 UTC
2020-04-07 00:00:00 UTC 2020-04-08 00:00:00 UTC
2020-04-08 00:00:00 UTC 2020-04-09 00:00:00 UTC
2020-04-09 00:00:00 UTC 2020-04-10 00:00:00 UTC
2020-04-10 00:00:00 UTC 2020-04-11 00:00:00 UTC
2020-04-11 00:00:00 UTC 2020-04-12 00:00:00 UTC
2020-04-12 00:00:00 UTC 2020-04-13 00:00:00 UTC
2020-04-13 00:00:00 UTC 2020-04-14 00:00:00 UTC
2020-04-14 00:00:00 UTC 2020-04-15 00:00:00 UTC
2020-04-15 00:00:00 UTC 2020-04-16 00:00:00 UTC
2020-04-16 00:00:00 UTC 2020-04-17 00:00:00 UTC
2020-04-17 00:00:00 UTC 2020-04-18 00:00:00 UTC
2020-04-18 00:00:00 UTC 2020-04-19 00:00:00 UTC
2020-04-19 00:00:00 UTC 2020-04-20 00:00:00 UTC
2020-04-20 00:00:00 UTC 2020-04-21 00:00:00 UTC
2020-04-21 00:00:00 UTC 2020-04-22 00:00:00 UTC
2020-04-22 00:00:00 UTC 2020-04-23 00:00:00 UTC
2020-04-23 00:00:00 UTC 2020-04-24 00:00:00 UTC
2020-04-24 00:00:00 UTC 2020-04-25 00:00:00 UTC
2020-04-25 00:00:00 UTC 2020-04-26 00:00:00 UTC
2020-04-26 00:00:00 UTC 2020-04-27 00:00:00 UTC
2020-04-27 00:00:00 UTC 2020-04-28 00:00:00 UTC
2020-04-28 00:00:00 UTC 2020-04-29 00:00:00 UTC
2020-04-29 00:00:00 UTC 2020-04-30 00:00:00 UTC
2020-04-30 00:00:00 UTC 2020-05-01 00:00:00 UTC
2020-05-01 00:00:00 UTC 2020-05-02 00:00:00 UTC
2020-05-02 00:00:00 UTC 2020-05-03 00:00:00 UTC
=> ((1585785600..1588377600).step(1 day))

#rails (32)
List