From ef4aa92311c416e223958c11b0de9642f69239f7 Mon Sep 17 00:00:00 2001 From: Michael Fross Date: Fri, 1 Dec 2023 10:54:41 -0600 Subject: [PATCH] Corrected holiday display with an odd number holidays The bottom left column was not formatted correctly if there was an odd number of holidays in the year --- pom.xml | 2 +- snap/snapcraft.yaml | 2 +- src/main/java/org/fross/cal/Calendar.java | 4 ++-- src/main/java/org/fross/cal/Holidays.java | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 7727d92..b61668c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.fross cal - 2.5.0 + 2.5.1 jar cal diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 111cc23..c2bf26a 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: fcal -version: '2.5.0' +version: '2.5.1' summary: Command line calendar display description: | fCal is a command line calendar utility. It will display a diff --git a/src/main/java/org/fross/cal/Calendar.java b/src/main/java/org/fross/cal/Calendar.java index 9c66491..56b3b08 100644 --- a/src/main/java/org/fross/cal/Calendar.java +++ b/src/main/java/org/fross/cal/Calendar.java @@ -185,7 +185,7 @@ public static void printYear(int year) { Output.debugPrintln("Width of calendar display for centering: " + displayWidth); // Display the holiday display header - String header = Holidays.queryCountry() + " holidays for " + year; + String header = year + " holidays for " + Holidays.queryCountry(); try { Output.printColorln(Ansi.Color.YELLOW, Format.CenterText(displayWidth, header)); } catch (Exception ex) { @@ -226,7 +226,7 @@ public static void printYear(int year) { } catch (ArrayIndexOutOfBoundsException ex) { // Display the left side and nothing on the right for odd number of holidays - Output.printColor(Ansi.Color.CYAN, keyLeft + ":" + holidayList.get(keyLeft)); + Output.printColor(Ansi.Color.CYAN, keyLeft.substring(5) + "|" + holidayList.get(keyLeft)); } catch (IllegalArgumentException ex) { Output.printColorln(Ansi.Color.RED, "ERROR: Could not display holiday list correctly"); diff --git a/src/main/java/org/fross/cal/Holidays.java b/src/main/java/org/fross/cal/Holidays.java index 4c9585e..cd6b838 100644 --- a/src/main/java/org/fross/cal/Holidays.java +++ b/src/main/java/org/fross/cal/Holidays.java @@ -45,6 +45,9 @@ public class Holidays { * * Date is in the format 'yyyy-mm-dd' * + * Can test via command line with "java -Duser.country=MX -jar target\cal.jar -d" or adding -Duser.country=MX to the + * debug/run configuration + * * @param year * @return */