|
6 | 6 | import seedu.address.model.person.UniquePersonList; |
7 | 7 | import seedu.address.model.schedule.Schedulable; |
8 | 8 |
|
| 9 | +import java.time.Duration; |
9 | 10 | import java.time.LocalDateTime; |
10 | 11 | import java.util.Collections; |
11 | 12 | import java.util.HashSet; |
|
23 | 24 | public class Meeting implements Schedulable { |
24 | 25 |
|
25 | 26 | public static final String MESSAGE_CONSTRAINTS = |
26 | | - "The start date time of a meeting should be strictly earlier than the terminate date time."; |
| 27 | + "The start date time of a meeting should be strictly earlier than the terminate date time. A meeting " |
| 28 | + + "should be at least 15 minutes long. A meeting should be at most one week long. For example:" |
| 29 | + + "If the meeting starts on 15 August 7:00 am, it should be at note end later than 22 Aug 6:59am"; |
27 | 30 |
|
28 | 31 |
|
29 | 32 | // Identity fields |
@@ -95,10 +98,13 @@ public boolean isSameMeeting(Meeting otherMeeting) { |
95 | 98 | && otherMeeting.getTerminate().equals(getTerminate()); |
96 | 99 | } |
97 | 100 | /** |
98 | | - * Returns true if a given date time for the meeting is valid. |
| 101 | + * Returns true if a given date time for the meeting is valid. Note the meeting must be at |
| 102 | + * least 15 mins long and at most 7 days long. |
99 | 103 | */ |
100 | 104 | public static boolean isValidStartTerminate(DateTime start, DateTime terminate) { |
101 | | - return start.compareTo(terminate) < 0; |
| 105 | + long minutesBetween = Duration.between(start.toLocalDateTime(), terminate.toLocalDateTime()).toMinutes(); |
| 106 | + long daysBetween = Duration.between(start.toLocalDateTime(), terminate.toLocalDateTime()).toDays(); |
| 107 | + return start.compareTo(terminate) < 0 && (minutesBetween >= 15) && (daysBetween < 7); |
102 | 108 | } |
103 | 109 | /** |
104 | 110 | * Adds new groups from a set. Merge if new group appears. |
|
0 commit comments