From 9bc94fed5759a0c37c34975aa32b9101fa829f96 Mon Sep 17 00:00:00 2001 From: Michael Fross Date: Wed, 2 Aug 2023 16:49:59 -0500 Subject: [PATCH] Fixed a bug with the timestamp and the `-n` switch If `-n` was provided to only show the indexes, the time stamp would revert to Eastern time. This was corrected. Also updated the timestamp to show the AM/PM in lower case right next to the time. --- pom.xml | 2 +- snap/snapcraft.yaml | 2 +- src/main/java/org/fross/quoter/Index.java | 11 ++++++++++- .../java/org/fross/quoter/QuoteConsoleOutput.java | 10 +++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 77b4f21..f692bce 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.fross quoter - 5.0.17 + 5.0.18 jar quoter diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 9c82aae..a3d8c5d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: quoter -version: '5.0.17' +version: '5.0.18' summary: Command line utility to pull stock and index quotes description: | Quoter fetches online stock quotes and index data for easy display on diff --git a/src/main/java/org/fross/quoter/Index.java b/src/main/java/org/fross/quoter/Index.java index d4f9f5c..27357c5 100644 --- a/src/main/java/org/fross/quoter/Index.java +++ b/src/main/java/org/fross/quoter/Index.java @@ -43,7 +43,7 @@ public class Index { HashMap indexData = new HashMap<>(); - static boolean marketOpen; + private boolean marketOpen; XPathLookup xPathLookup = new XPathLookup(); /** @@ -55,6 +55,15 @@ public Index(String idx) { getIndex(idx); } + /** + * MarketOpen(): Returns if the US index market is currently open + * + * @return + */ + public boolean queryMarketOpen() { + return marketOpen; + } + /** * queryPageItem():Find the specific value in the provided doc with the xPath given * diff --git a/src/main/java/org/fross/quoter/QuoteConsoleOutput.java b/src/main/java/org/fross/quoter/QuoteConsoleOutput.java index d180cfe..fd15f9b 100644 --- a/src/main/java/org/fross/quoter/QuoteConsoleOutput.java +++ b/src/main/java/org/fross/quoter/QuoteConsoleOutput.java @@ -238,8 +238,8 @@ public void displayOutput(FileExporter exporter) { } // Display the open/closed status of the market - Output.printColor(Ansi.Color.CYAN, "\nThe US index markets are currently: "); - if (Index.marketOpen == true) { + Output.printColor(Ansi.Color.CYAN, "\nThe US markets are currently: "); + if (new Index("DOW").queryMarketOpen() == true) { Output.printColorln(Ansi.Color.YELLOW, "~ OPEN ~"); } else { Output.printColorln(Ansi.Color.YELLOW, "~ CLOSED ~"); @@ -266,7 +266,7 @@ public void displayOutput(FileExporter exporter) { ZonedDateTime zdtDest = zdtSrc.withZoneSameInstant(destTimeZone); // Build the updated time stamp - timeStamp = zdtDest.format(DateTimeFormatter.ofPattern("MMM dd yyyy hh:mm a z (O)")); + timeStamp = zdtDest.format(DateTimeFormatter.ofPattern("MMM dd yyyy hh:mma z (O)")); } catch (DateTimeParseException ex) { // Just take the original time stamp from the financial website after adding the time zone @@ -274,6 +274,10 @@ public void displayOutput(FileExporter exporter) { } } + // Changed the AM/PM to lower case as I think it looks better + timeStamp = timeStamp.replaceAll("PM","pm"); + timeStamp = timeStamp.replaceAll("AM","am"); + // Display the time stamp Output.printColor(Ansi.Color.CYAN, "Data as of "); Output.printColor(Ansi.Color.WHITE, timeStamp);