diff --git a/pom.xml b/pom.xml index aa26ec3..534d9d3 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.fross cal - 2.3.12 + 2.3.13 jar cal diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 14ba20e..db2d7ef 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: fcal -version: '2.3.12' +version: '2.3.13' summary: Command line calendar display description: | fCal is a command line calendar display 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 2247728..fae43d4 100644 --- a/src/main/java/org/fross/cal/Calendar.java +++ b/src/main/java/org/fross/cal/Calendar.java @@ -37,8 +37,8 @@ public class Calendar { // Class Constants static final int DEFAULT_CALS_PER_ROW = 3; static final int CALENDARWIDTH = 20; - static final int SPACESBETWEENCALS = 3; - static final String[] MONTHLIST = { "none", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", + static final int SPACESBETWEENCALS = 2; + static final String[] MONTHLIST = { "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; // Class Variables @@ -100,6 +100,9 @@ public static boolean isLeapYear(int year) { public static void printMonth(int month, int year) { String[] days = getCalDays(month, year); + Output.debugPrint(" 1 2 3 4 5 6 7 8\n" + + "12345678901234567890123456789012345678901234567890123456789012345678901234567890"); + Output.printColorln(Ansi.Color.CYAN, getCalHeader(month, year)); Output.printColorln(Ansi.Color.YELLOW, "Su Mo Tu We Th Fr Sa"); @@ -119,6 +122,9 @@ public static void printYear(int month, int year) { String[] dayrows = new String[6]; int i, j, k; + Output.debugPrint(" 1 2 3 4 5 6 7 8\n" + + "12345678901234567890123456789012345678901234567890123456789012345678901234567890"); + // Loop through the calendar rows for (i = 0; i < 12; i = i + calsPerRow) { // Initialize the arrays diff --git a/src/main/java/org/fross/cal/Main.java b/src/main/java/org/fross/cal/Main.java index 19d905f..fc897d1 100644 --- a/src/main/java/org/fross/cal/Main.java +++ b/src/main/java/org/fross/cal/Main.java @@ -116,7 +116,6 @@ public static void main(String[] args) { default: Output.fatalError("ERROR: Unknown Command Line Option -" + optG.getOptarg() + "'", 0); Help.display(); - break; } } @@ -131,31 +130,19 @@ public static void main(String[] args) { Output.debugPrint("Number of command line arguments: " + args.length); int clParameters = args.length - optG.getOptind(); Output.debugPrint("Number of command line parameters: " + clParameters); - Output.debugPrint("Current Date: Month: " + month + " Year: " + year); - -// DISABLE THIE HEADER AS IT SEEMS OBTRUSIVE -// // Display header information -// int headerWidth = (Calendar.CALENDARWIDTH * Calendar.calsPerRow) + (Calendar.calsPerRow * Calendar.SPACESBETWEENCALS) - 2; -// String headerText = "Cal v" + VERSION + " by Michael Fross"; -// int headerSpaces = headerWidth / 2 - headerText.length() / 2; -// -// // Ensure we have enough room if user selects -n1 -// if (headerSpaces < 0) { -// headerSpaces = 0; -// headerWidth = headerText.length(); -// } -// -// Output.debugPrint("headerWidth = " + headerWidth); -// Output.debugPrint("headerText = " + "'" + headerText + "' (Len = " + headerText.length() + ")"); -// Output.debugPrint("headerSpaces = " + headerSpaces); -// -// Output.printColorln(Ansi.Color.CYAN, "\n+" + "-".repeat(headerWidth) + "+"); -// Output.printColorln(Ansi.Color.YELLOW, " ".repeat(headerSpaces) + headerText); -// Output.printColorln(Ansi.Color.CYAN, "+" + "-".repeat(headerWidth) + "+"); + Output.debugPrint("Current Date: Month: " + month + " Year: " + year); + + // Ensure the month and year are greater than zero + for (int i=0; i < clParameters; i++) { + if (args[i].compareTo("0") == 0) { + Output.fatalError("Month & Year must be greater than zero", 6); + } + } // Process options and display the calendar try { Output.println(""); + switch (clParameters) { case 0: // Process no dates provided @@ -171,8 +158,6 @@ public static void main(String[] args) { if (d > 12) { year = d; Output.debugPrint("Commandline Year provided. Using Month: " + month + " Year: " + year); - Output.debugPrint(" 1 2 3 4 5 6 7"); - Output.debugPrint("90123456789012345678901234567890123456789012345678901234567890"); Calendar.printYear(month, year); // Assume the number provided is a month