不定期日記

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

2001|01|07|08|09|10|11|12|
2002|01|02|03|
2003|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|08|09|10|11|12|
2017|03|05|06|09|11|12|
2018|05|08|10|11|
2020|07|