Skip to content

Commit

Permalink
Corrected holiday display with an odd number holidays
Browse files Browse the repository at this point in the history
The bottom left column was not formatted correctly if there was an odd
number of holidays in the year
  • Loading branch information
frossm committed Dec 1, 2023
1 parent ff2076e commit ef4aa92
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.fross</groupId>
<artifactId>cal</artifactId>
<version>2.5.0</version>
<version>2.5.1</version>
<packaging>jar</packaging>

<name>cal</name>
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/fross/cal/Calendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/fross/cal/Holidays.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit ef4aa92

Please sign in to comment.