Prev / Next / あかぴのChangeLog by rchalow

after311.rb[rubyの勉強]

2012-08-04

after311.rb [rubyの勉強]

2011/3/11からの経過日数を数えるプログラム

#!/usr/bin/env ruby
$KCODE="EUC"

require "date"
d = Date.today
d311 = Date.new(2011, 3 ,11)
d_in = ARGV[0]
d1 = Date.parse(d_in.to_s)

print d311,"からの日数","\n"
print "今日:", d ," ,", d - d311,"日後","\n"
print " :",d1 ," ,", d1 - d311,"日後","\n"

実行結果
$ ./after311.rb 20110312
2011-03-11からの日数
今日:2012-08-04 ,512日後
    :2011-03-12 ,1日後

512日後

blog comments powered by Disqus