不定期日記
J2千葉観戦記, ライブの感想を中心とした備忘録
2014-02-27 (Thu) [長年日記]
_ [JEF][PC] ジェフユナイテッド市原・千葉試合日程
今週末からリーグ戦が始まってしまうので、いつものごとくカレンダーに入力。
4年前に作ったスクリプトを一部修正した。 (年をオプションで指定するようにしただけ)
#!/usr/local/bin/ruby
#
## 入力データ(タブ区切りテキスト, SJIS)
# 4 3月28日 日 16:00 ザスパ草津 フクアリ
require 'nkf'
require 'getoptlong'
parser = GetoptLong.new
parser.set_options( ['--year', '-y', GetoptLong::REQUIRED_ARGUMENT] )
begin
while getopt = parser.get_option
year = getopt[1] if getopt[0] == '--year'
end
rescue
end
if (ARGV.empty? || year.nil?) then
puts "Usage: jefschedule.rb input.txt --year|-y year"
exit;
end
outfile = "cal.csv"
stadiums = ["フクアリ", "市原", "秋津", "東総", "SHプレテク", "東金", "鴨川"].collect { |item| NKF::nkf("-s", item) }
o = open(outfile, "w")
o.print NKF::nkf("-s", <<EOD)
"件名","開始日","開始時刻","終了日","終了時刻","終日イベント","アラーム オン/オフ"
EOD
while line = gets
line = line.chomp("\n").split("\t")
if stadiums.include?(line[5].chomp(" ")) then
home = "h"
else
home = "a"
end
o.print "\"#{line[0]}#{home}#{line[4].chomp(" ")}@#{line[5]}\","
date = line[1].sub(/([0-9]+)[^0-9]+([0-9]+)[^0-9]*/, "\"#{year}/\\1/\\2\"")
o.print "#{date},"
o.print line[3].chomp("\s") + ":00,"
o.print "#{date},"
o.print "#{$1.to_i + 2}:#{$2}:00," if line[3] =~/([0-9]+):([0-9]+)[^0-9]*/
o.puts "FALSE,FALSE"
end
o.close
[ツッコミを入れる]
2020|07|
