 module.exports = (robot) ->
     #毎年1/1の1時に祝日データの更新
     new cron('0 1 1 1 *', () ->
-        now = new Date
-        year = now.getFullYear()
-        key = "publicHoliday_#{year}"
-        robot.brain.data[key] = []
-        brainPublicHoliday(year,robot)
+        updatePublickHoliday(new Date)
     ).start()
 
     #毎日午前3時にその曜日の時刻表を取得し，データを更新する(エラー処理などはそのうち追加
+    # TO DO : cronで叩くとなぜかエラーが出るのなんとかする
+    # まあ最悪自分にリプライ投げるみたいな雑な対策で
     new cron('0 3 * * *', () ->
         now = new Date
         console.log "午前3時:#{now}"
         #dayIndex = getDayOfWeek(now,robot)
         #getBusSchedule(allDay[dayIndex],url[dayIndex],robot)
     ).start()
-
-    #robot.respond /public holiday/i, (msg) ->
-    #    d = new Date
-    #    key = "publicHoliday_#{d.getFullYear()}"
-    #    console.log robot.brain.data[key]
 
     #次のバスを表示（デフォルトでは10分後）
     robot.respond /bus(.*)/i, (msg) ->

            getBusSchedule("minakusa",value,url[index],robot)
            console.log "#{value}:#{urlKusatsu[index]}"
            getBusSchedule("kusatsu",value,urlKusatsu[index],robot)

#曜日の要素取得
getDayOfWeek = (now,robot) ->

            hour = 5
        count = 0
        busHour = hour
        replyMessage = "\n#{toName}行き \n"

        while count < 5 or hour+2 > busHour
            nextBus = []
            key = "#{to}_#{allDay[dayIndex]}_time#{busHour}"
            while robot.brain.data[key] is null and busHour <= 24
                busHour++

            if busHour > 24
                replyMessage += "最後のバスです"
                break

            for value, index in robot.brain.data[key]
                tmpTime = parseInt(value.match(/\d{2}/))
                #シャトルバスの場合の判定
                if not tmpBus = value.match(/\D/)
                    tmpBus = viaS[0]
                if (busHour > hour and ///#{bus}///.test(tmpBus))
                    or (tmpTime > min and ///#{bus}///.test(tmpBus))
                    nextBus.push(value)
                    count++
                if count < 5
                    break
            replyMessage += "#{busHour}時：#{nextBus.join()}"
            replyMessage += "\n"
            busHour++
        msg.reply replyMessage

    #コマンドから全てのバスの時刻表を取得
    robot.respond /data update/i, (msg) ->
        console.log "get data now"
        now = new Date
        brainPublicHoliday(now.getFullYear(),robot)
