Skip to content

Commit

Permalink
Make sure there's a non-Zero-duration Home-time, before giving room i…
Browse files Browse the repository at this point in the history
…n the output (so no newlines for non-existing entries
  • Loading branch information
ThatCraws committed Jun 14, 2024
1 parent 32e1836 commit e69451b
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ public String createOutput(WorkWeek workWeek) {
StringBuilder output = new StringBuilder();

for (WorkDay day : workWeek.getWorkDays()) {
output.append(DateTimeFormatUtils.workDayFormat(day, workWeek.getCalendarWeek()));
output.append("\n");
appendDay(output, workWeek.getCalendarWeek(), day);
}

return new String(output);
}

private void appendDay(final StringBuilder toAppendTo, final int calendarWeek, final WorkDay workDay) {
if (workDay.getHomeTime() == null || workDay.getHomeTime().getWorkDuration().isZero()) {
return;
}

toAppendTo.append(DateTimeFormatUtils.workDayFormat(workDay, calendarWeek));
toAppendTo.append("\n");
}
}

0 comments on commit e69451b

Please sign in to comment.