こんどは Ruby で。
require 'date' y, m, d = ARGV.map{|arg| arg.to_i } date = Date.new(y, m, d) sunday = (date - date.wday) (1..5).each do |d| puts((sunday + d).strftime("%Y-%m-%d %a")) end
実行。
^o^ >week.rb 2007 7 7 2007-07-02 Mon 2007-07-03 Tue 2007-07-04 Wed 2007-07-05 Thu 2007-07-06 Fri ^o^ >week.rb 2007 1 1 2007-01-01 Mon 2007-01-02 Tue 2007-01-03 Wed 2007-01-04 Thu 2007-01-05 Fri ^o^ >week.rb 2007 12 30 2007-12-31 Mon 2008-01-01 Tue 2008-01-02 Wed 2008-01-03 Thu 2008-01-04 Fri