Skip to content

Commit

Permalink
Merge pull request #206 from nixonwidjaja/master
Browse files Browse the repository at this point in the history
Fix leave bugs
  • Loading branch information
nixonwidjaja committed Nov 13, 2023
2 parents 913403c + 6f7a334 commit 52d2b10
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ Format: `leave INDEX m/MONTHS`
- The `INDEX` **must be a positive integer** 1,2,3, ...
- The `MONTHS` refers to the month of the leave the employee is taking in integer format (between 1-12).
- Positive `MONTHS` add leaves on the specified months and negative `MONTHS` remove them.
- Trailing commas in `MONTHS` (`leave 1 m/1,2,3,,,`) will be ignored, but empty months elsewhere (`leave 1 m/1,,,2`) will raise an error.

Examples:
- `list` followed by `leave 1 m/3,4` adds leaves in March and April for the 1st employee in the list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private String parseLeave(String arg) throws ParseException {
StringBuilder months = new StringBuilder(Leave.NO_LEAVE);
String[] args = arg.split(",");
for (int i = 0; i < args.length; i++) {
if (args[i].length() > 3) {
if (args[i].length() <= 0 || args[i].length() > 3) {
throw new ParseException(LeaveCommand.MESSAGE_INVALID_MONTH + LeaveCommand.MESSAGE_USAGE);
}
try {
Expand Down

0 comments on commit 52d2b10

Please sign in to comment.