Skip to content

Commit

Permalink
Use slap for setLength method under add command
Browse files Browse the repository at this point in the history
Use slap for setLength method under add command
  • Loading branch information
swxsw committed Nov 6, 2016
1 parent d2456b0 commit ec98333
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/todoit/taskbook/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ private String setLength(String length, String datetime, String endDatetime) thr
LocalDateTime startDate = DateParser.parseDate(datetime);
LocalDateTime endDate = DateParser.parseDate(endDatetime);
long hourDifference = ChronoUnit.HOURS.between(startDate, endDate);
if(hourDifference >= 24){
return Long.toString(TimeUnit.HOURS.toDays(hourDifference)) + "d";
} else {
return hourDifference + "h";
}
String finalTimeDifference = getDifferenceString(hourDifference);
return finalTimeDifference;
}
} else {
if(!endDatetime.equals("-1")){
Expand All @@ -83,6 +80,14 @@ private String setLength(String length, String datetime, String endDatetime) thr
return length;
}
}

private String getDifferenceString(long hourDifference){
if(hourDifference >= 24){
return Long.toString(TimeUnit.HOURS.toDays(hourDifference)) + "d";
} else {
return hourDifference + "h";
}
}

public AddCommand(String name, String priority, String information, String doneFlag, Set<String> tagsFromArgs)
throws IllegalValueException {
Expand Down

0 comments on commit ec98333

Please sign in to comment.