Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Exclusive end time for FreeTime #260

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class FreeTime implements Comparable<FreeTime> {
+ "Day is case-insensitive.";

public static final String VALIDATION_REGEX = "^(?i)(monday|tuesday|wednesday|thursday|friday|saturday|sunday) "
+ "([01]?\\d|2[0-3])(00|30) ([01]?\\d|2[0-3])(00|30)$"; //format: (case-insensitive) day 2359 2359
+ "([01]?\\d|2[0-3])(00|30) (([01]?\\d|2[0-3])(00|30)|(2400))$";

public final String freeTimeString;
private final DayOfWeek day;
Expand Down Expand Up @@ -47,6 +47,9 @@ public FreeTime(String freeTime) {
* Returns true if a given string is a valid tag name.
*/
public static boolean isValidFreeTime(String test) {
if (!test.matches(VALIDATION_REGEX)) {
System.out.println("YOUR INPUT DOESN'T WORK" + test);
}
return test.matches(VALIDATION_REGEX);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public static Module newModule(String unparsedInput) throws IllegalValueExceptio

// Check for valid number of parts
if (parts.length != 4) {
throw new IllegalArgumentException("Invalid module input format. Expected: NAME DAY HHMM HHMM");
String errorMsg = "Invalid module input format. Expected: NAME DAY HHMM HHMM" + MESSAGE_CONSTRAINTS;
throw new IllegalArgumentException(errorMsg);
}

String name = parts[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ public List<FreeTime> getThisWeeksFreeTime() {
startSlot = slot;
} else if (timeSlots[day][slot] && startSlot != -1) {
// End of a free time slot
freeTimes.add(createFreeTime(day, startSlot, slot - 1));
freeTimes.add(createFreeTime(day, startSlot, slot));
startSlot = -1;
}
}
if (startSlot != -1) {
freeTimes.add(createFreeTime(day, startSlot, 47)); // The entire day is free.
freeTimes.add(createFreeTime(day, startSlot, 48)); // The entire day is free.
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class TimeBlock implements Comparable<TimeBlock> {
+ "Day is case-insensitive. The start time must be before the end time.";

public static final String VALIDATION_REGEX = "^(?i)(monday|tuesday|wednesday|thursday|friday|saturday|sunday) "
+ "([01]?\\d|2[0-3])(00|30) ([01]?\\d|2[0-3])(00|30)$"; //format: (case-insensitive) day 2359 2359
+ "([01]?\\d|2[0-3])(00|30) (([01]?\\d|2[0-3])(00|30)|(2400))$"; //format: (case-insensitive) day 2359 2359

private String timeBlockString;
private final DayOfWeek day;
Expand Down
Loading