Skip to content

Commit

Permalink
Fixed a bug with the timestamp and the -n switch
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
frossm committed Aug 2, 2023
1 parent e384b6d commit 9bc94fe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 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>quoter</artifactId>
<version>5.0.17</version>
<version>5.0.18</version>
<packaging>jar</packaging>

<name>quoter</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: 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
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/org/fross/quoter/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

public class Index {
HashMap<String, String> indexData = new HashMap<>();
static boolean marketOpen;
private boolean marketOpen;
XPathLookup xPathLookup = new XPathLookup();

/**
Expand All @@ -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
*
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/fross/quoter/QuoteConsoleOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ~");
Expand All @@ -266,14 +266,18 @@ 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
timeStamp = timeStamp + " Eastern Time";
}
}

// 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);
Expand Down

0 comments on commit 9bc94fe

Please sign in to comment.