public static PreEvent copyEvent(long guildId, Event event) { PreEvent pe = new PreEvent(guildId); pe.setSummary(event.getSummary()); pe.setDescription(event.getDescription()); pe.setLocation(event.getLocation()); if (event.getColorId() != null) pe.setColor(EventColor.fromNameOrHexOrID(event.getColorId())); else pe.setColor(EventColor.RED); pe.setEventData(DatabaseManager.getManager().getEventData(guildId, event.getId())); return pe; } }
/** * Checks whether or not the start date is after the end date of the event. * * @param startRaw The date to check in format (yyyy/MM/dd-HH:mm:ss). * @param timezone The timezone of the calendar this event is for. * @param event The event that is currently being created. * @return <code>true</code> of the start is after the end, otherwise <code>false</code>. */ public static boolean startAfterEnd(String startRaw, TimeZone timezone, PreEvent event) { if (event.getEndDateTime() != null) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss"); sdf.setTimeZone(timezone); Date startDate = sdf.parse(startRaw); Date endDate = new Date(event.getEndDateTime().getDateTime().getValue()); return startDate.after(endDate); } catch (ParseException e) { return true; } } return false; }
/** * Checks whether or not the end date is before the start date of the event. * * @param endRaw The date to check in format (yyyy/MM/dd-HH:mm:ss). * @param timezone The timezone of the calendar this event is for. * @param event The event that is currently being created. * @return <code>true</code> if the end is before the start, otherwise <code>false</code>. */ public static boolean endBeforeStart(String endRaw, TimeZone timezone, PreEvent event) { if (event.getStartDateTime() != null) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss"); sdf.setTimeZone(timezone); Date endDate = sdf.parse(endRaw); Date startDate = new Date(event.getStartDateTime().getDateTime().getValue()); return endDate.before(startDate); } catch (ParseException e) { return true; } } return false; }