From 2af0eaebddb8d1a01ded18e4dffa488a3552cab6 Mon Sep 17 00:00:00 2001 From: fabianArbeit Date: Thu, 8 Aug 2024 12:47:59 +0200 Subject: [PATCH] =?UTF-8?q?offset=20f=C3=BCr=20Zeit=20vor=20Mittagspause?= =?UTF-8?q?=20eingebaut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LoadingBar.java | 63 +++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/LoadingBar.java b/LoadingBar.java index 3e225a6..871e05a 100644 --- a/LoadingBar.java +++ b/LoadingBar.java @@ -79,6 +79,10 @@ class LoadingBar { return; } String nextArg = args[2]; + if (OFFSET_PATTERN.matcher(nextArg).matches()) { + showLoadingBarMittagspause(startTime, Integer.parseInt(nextArg)); + return; + } verifyTimeFormat(nextArg, "Argument nach " + DaySection.MITTAG.getParam()); var maxMittagspause = LocalTime.parse(nextArg, TIME_FORMATTER); showLoadingBarMittagspause(startTime, maxMittagspause); @@ -178,31 +182,33 @@ class LoadingBar { private static void printHelp() { - System.out.println(new StringBuilder().append("Mögliche Argumente für LoadingBar:\n") - .append("Normalfall Vormittag (Mittagspause <= ").append(LATEST_LUNCH_TIME).append(")\n") - .append(TIME_FORMAT).append(" ").append(DaySection.MITTAG.getParam()).append("\n") - .append("Vormittag mit expliziter Mittagspause (<= ").append(LATEST_LUNCH_TIME).append(")\n") - .append(TIME_FORMAT).append(" ").append(DaySection.MITTAG.getParam()).append(" ").append(TIME_FORMAT).append("\n") - .append("Normalfall Nachmittag (Mittagspause ").append(MIN_LUNCH_DURATION).append(" min)\n") - .append(TIME_FORMAT).append(" ").append(DaySection.ZAPFENSTREICH.getParam()).append("\n") - .append("Nachmittag mit expliziter Länge Mittagspause (Mittagspause unter ").append(MIN_LUNCH_DURATION).append(" min wird auf ").append(MIN_LUNCH_DURATION).append(" min korrigiert)\n") - .append(TIME_FORMAT).append(" ").append(DaySection.ZAPFENSTREICH.getParam()).append(" mm\n") - .append("Nachmittag mit explizitem Feierabend (Mittagspause je nach Minimum (s.u.))\n") - .append(TIME_FORMAT).append(" ").append(DaySection.ZAPFENSTREICH.getParam()).append(" ").append(TIME_FORMAT).append("\n") - .append("Nachmittag mit abweichender Minutenanzahl Arbeitszeit\n") - .append(TIME_FORMAT).append(" ").append(DaySection.ZAPFENSTREICH.getParam()).append(" -+mm\n") - .append("Nachmittag mit explizitem Feierabend u. expliziter Länge Mittagspause (Mittagspause unter Minimum (s.u.) wird auf Minimum korrigiert)\n") - .append(TIME_FORMAT).append(" ").append(DaySection.ZAPFENSTREICH.getParam()).append(" mm ").append(TIME_FORMAT).append("\n") - .append("Nachmittag mit explizitem Feierabend u. abweichender Minutenanzahl Arbeitszeit\n") - .append(TIME_FORMAT).append(" ").append(DaySection.ZAPFENSTREICH.getParam()).append(" ").append(TIME_FORMAT).append(" -+mm\n\n") - .append("Mittagspause minimum in Minuten:\n") - .append(" - bis ").append(MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH).append(" min (") - .append(MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH / 60).append(" std): 0\n") - .append(" - bis ").append(MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH).append(" min + ") - .append(MIN_LUNCH_DURATION).append(" min: Arbeitszeit - ").append(MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH).append(" min\n") - .append(" - ab ").append(MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH).append(" min + ").append(MIN_LUNCH_DURATION).append(" min: ") - .append(MIN_LUNCH_DURATION).append(" min\n") - .toString()); + System.out.println("Mögliche Argumente für LoadingBar:\n" + + "Normalfall Vormittag (Mittagspause <= " + LATEST_LUNCH_TIME + ")\n" + + TIME_FORMAT + " " + DaySection.MITTAG.getParam() + "\n" + + "Vormittag mit expliziter Mittagspause (<= " + LATEST_LUNCH_TIME + ")\n" + + TIME_FORMAT + " " + DaySection.MITTAG.getParam() + " " + TIME_FORMAT + "\n" + + "Vormittag mit abweichender Minutenanzahl Arbeitszeit\n" + + TIME_FORMAT + " " + DaySection.MITTAG.getParam() + " -+mm\n" + + "Normalfall Nachmittag (Mittagspause " + MIN_LUNCH_DURATION + " min)\n" + + TIME_FORMAT + " " + DaySection.ZAPFENSTREICH.getParam() + "\n" + + "Nachmittag mit expliziter Länge Mittagspause (Mittagspause unter " + MIN_LUNCH_DURATION + " min wird auf " + MIN_LUNCH_DURATION + " min korrigiert)\n" + + TIME_FORMAT + " " + DaySection.ZAPFENSTREICH.getParam() + " mm\n" + + "Nachmittag mit explizitem Feierabend (Mittagspause je nach Minimum (s.u.))\n" + + TIME_FORMAT + " " + DaySection.ZAPFENSTREICH.getParam() + " " + TIME_FORMAT + "\n" + + "Nachmittag mit abweichender Minutenanzahl Arbeitszeit\n" + + TIME_FORMAT + " " + DaySection.ZAPFENSTREICH.getParam() + " -+mm\n" + + "Nachmittag mit explizitem Feierabend u. expliziter Länge Mittagspause (Mittagspause unter Minimum (s.u.) wird auf Minimum korrigiert)\n" + + TIME_FORMAT + " " + DaySection.ZAPFENSTREICH.getParam() + " mm " + TIME_FORMAT + "\n" + + "Nachmittag mit explizitem Feierabend u. abweichender Minutenanzahl Arbeitszeit\n" + + TIME_FORMAT + " " + DaySection.ZAPFENSTREICH.getParam() + " " + TIME_FORMAT + " -+mm\n\n" + + "Mittagspause minimum in Minuten:\n" + + " - bis " + MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH + " min (" + + MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH / 60 + " std): 0\n" + + " - bis " + MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH + " min + " + + MIN_LUNCH_DURATION + " min: Arbeitszeit - " + MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH + " min\n" + + " - ab " + MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH + " min + " + MIN_LUNCH_DURATION + " min: " + + MIN_LUNCH_DURATION + " min\n" + ); } @@ -211,6 +217,13 @@ class LoadingBar { } + private static void showLoadingBarMittagspause(LocalTime startTime, int endTimeOffset) { + LocalTime endTime = startTime.plusMinutes(DEFAULT_NUMBER_WORK_MINS_BEFORE_LUNCH + endTimeOffset); + LocalTime trueEndTime = endTime.isAfter(LATEST_LUNCH_TIME) ? LATEST_LUNCH_TIME : endTime; + showLoadingBar(startTime, trueEndTime); + } + + private static void showLoadingBarMittagspause(LocalTime startTime, LocalTime manualEndTime) { LocalTime endTime = manualEndTime != null ? manualEndTime : startTime.plusMinutes(DEFAULT_NUMBER_WORK_MINS_BEFORE_LUNCH); LocalTime trueEndTime = endTime.isAfter(LATEST_LUNCH_TIME) ? LATEST_LUNCH_TIME : endTime;