Skip to content

Commit 4afe902

Browse files
committed
Add minimum time to meetings
Add minimum time of 15 mins and max time of 7 days Will not allow user to give very long days to try and break the program
1 parent a510095 commit 4afe902

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/main/java/seedu/address/model/meeting/Meeting.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import seedu.address.model.person.UniquePersonList;
77
import seedu.address.model.schedule.Schedulable;
88

9+
import java.time.Duration;
910
import java.time.LocalDateTime;
1011
import java.util.Collections;
1112
import java.util.HashSet;
@@ -23,7 +24,9 @@
2324
public class Meeting implements Schedulable {
2425

2526
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";
2730

2831

2932
// Identity fields
@@ -95,10 +98,13 @@ public boolean isSameMeeting(Meeting otherMeeting) {
9598
&& otherMeeting.getTerminate().equals(getTerminate());
9699
}
97100
/**
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.
99103
*/
100104
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);
102108
}
103109
/**
104110
* Adds new groups from a set. Merge if new group appears.

0 commit comments

Comments
 (0)