From e69451bf68dc9966a2fd2d974ac1655887b6fe20 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 14 Jun 2024 17:34:32 +0200 Subject: [PATCH] Make sure there's a non-Zero-duration Home-time, before giving room in the output (so no newlines for non-existing entries --- .../ouputter/TemplateStringWorkWeekOutputter.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/esterlino/timeplater/worktimes/ouputter/TemplateStringWorkWeekOutputter.java b/src/main/java/de/esterlino/timeplater/worktimes/ouputter/TemplateStringWorkWeekOutputter.java index 63eecc1..d2b42e5 100644 --- a/src/main/java/de/esterlino/timeplater/worktimes/ouputter/TemplateStringWorkWeekOutputter.java +++ b/src/main/java/de/esterlino/timeplater/worktimes/ouputter/TemplateStringWorkWeekOutputter.java @@ -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"); + } }