# $Id: schedule.rb,v 1.1.1.1 2000/11/23 10:34:06 not Exp $ # edit 2001.3.15 =begin schedule.rb nDiary Plug-in スケジュールの表示 今後のスケジュールを表示します。 option: format=str str は任意の文字列。以下の文字列は展開されます。 %A 曜日の名称(Sunday, Monday...) %a 曜日の省略名(Sun, Mon...) %B 月の名称(January, February...) %b 月の省略名(Jan, Feb...) %c 日付と時刻 %d 日(01-31) %j 年中の通算日(001-366) %m 月を表す数字(01-12) %U 週を表す数.最初の日曜日が第1週の始まり(00-53) %W 週を表す数.最初の月曜日が第1週の始まり(00-53) %w 曜日を表す数.日曜日が0(0-6) %x 日付 %Y 西暦を表す数 %y 西暦の下2桁(00-99) %% %自身 title=str スケジュールに付けるタイトルを指定します。 max=num 表示する最大行数 past=num num日前の経過してしまった日付の情報から表示します exsample: =end def plug(opt) max = 8 if opt['max'].to_i == 0 today = Time::now past = today - opt['past'].to_i * 86400 coming = today + 30 * 86400 start = past.strftime("%Y%m%d") last = coming.strftime("%Y%m%d") #####check##### now = today.strftime("%Y%m%d") schedule = {} opt['format'] = opt['format'] ? opt['format'] : '%0m/%0d' begin open(opt['file'], 'r'){ |file| file.each{ |line| date, value = line.split(/\t/) date.gsub!(/[-\/]/, '') if start <= date and date <= last then schedule[date] = [] unless schedule[date] schedule[date] << value end } } rescue Errno::ENOENT return '' end max = opt['max'].to_i max = 8 if max == 0 cnt = 0 str = '' #####check##### # str << "