/** Sets the time of the next scheduled raid */ private void setNextRaid(Info info) { String raidTime = info.getMessage().substring(13); raidTime = substituteTimeZone(raidTime); try { SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm z"); Date date = parser.parse(raidTime); TimeZone z = parser.getTimeZone(); GregorianCalendar cal = new GregorianCalendar(z); cal.setTime(date); raids.put(info.getChannel(), cal); saveRaids(); info.sendMessage("Raid time set."); } catch (ParseException e) { info.sendMessage( "Date format was bad. Date format is like \"2008-11-26 21:45 EST\". You entered " + raidTime); } }
private void nextRaid(Info info) { GregorianCalendar nextRaid = raids.get(info.getChannel()); GregorianCalendar now = Utils.getRealDate(info); int diffMins = (int) ((nextRaid.getTimeInMillis() - now.getTimeInMillis()) / 1000 / 60); if (nextRaid.compareTo(now) < 0) { info.sendMessage("There is no future raid set."); return; } String tz = info.getMessage().substring(9).trim(); tz = substituteTimeZone(tz); TimeZone timeZone; if (tz.length() == 0) timeZone = tZF("GMT"); else timeZone = tZF(tz); formatter.setTimeZone(timeZone); String ret = "The next raid is scheduled for " + formatter.format(nextRaid.getTime()); ret = ret + getTimeDifference(diffMins); info.sendMessage(ret); }