以下の内容はhttps://tbpgr.hatenablog.com/entry/20120618/1340038560より取得しました。


書籍 Ruby Cookbook | 日付のイテレーション

パンくず

Ruby Cookbook
日付のイテレーション

概要

日付のイテレーション

サンプル

# encoding: Windows-31J
require 'date'

today = Date.today
ten_date_after = today + 10
now = Time.now
puts today
puts ten_date_after
puts now
puts "----------------------------------------------"
today.upto(ten_date_after).each {|date|
  puts date
}
puts "----------------------------------------------"
ten_date_after.downto(today).each {|date|
  puts date
}
puts "----------------------------------------------"
(0..10).each {|num|
  today = today.succ
  puts today
}

出力

2012-06-19
2012-06-29
2012-06-19 01:54:08 +0900
----------------------------------------------
2012-06-19
2012-06-20
2012-06-21
2012-06-22
2012-06-23
2012-06-24
2012-06-25
2012-06-26
2012-06-27
2012-06-28
2012-06-29
----------------------------------------------
2012-06-29
2012-06-28
2012-06-27
2012-06-26
2012-06-25
2012-06-24
2012-06-23
2012-06-22
2012-06-21
2012-06-20
2012-06-19
----------------------------------------------
2012-06-20
2012-06-21
2012-06-22
2012-06-23
2012-06-24
2012-06-25
2012-06-26
2012-06-27
2012-06-28
2012-06-29
2012-06-30



以上の内容はhttps://tbpgr.hatenablog.com/entry/20120618/1340038560より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14