Skip to content

Commit

Permalink
Timestamp will now display in localized date
Browse files Browse the repository at this point in the history
Also updated screenshots and tweaked README
  • Loading branch information
frossm committed Jul 11, 2023
1 parent 14aff3d commit ebcab1b
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ If you frequently check the same set of securities, as I do, you can save them i
Running Quoter with `-r` will remove any saved quotes. Running with `-i` will ignore the saved quotes for that execution. Running with a `-l` will list your current saved favorites.

## Trending
<img align="right" width="200" src="https://github.com/frossm/quoter/raw/master/graphics/PostIt-512x512.jpg">This powerful feature will display approximately three months of trending data. The dates are on the Y axis, an the cost is on the X axis.
<img align="right" width="200" src="https://github.com/frossm/quoter/raw/master/graphics/PostIt-512x512.jpg">This powerful feature will display the requested (with `-d`) days to trend. The default is 90 days. The dates are on the Y axis, an the cost is on the X axis, you just tilt your head to the right (like you were eating a taco) and you'll be set :-)

It's executed by giving Quoter the **`-t`** command line switch. If there are 5 symbols on the command line, it will trend them all.
It's executed by giving Quoter the **`-t`** command line switch. If there are 5 symbols on the command line, it will trend them all in sequence.

The display will show you the last three months of data with the daily range and the close price.

Expand Down
Binary file removed graphics/ScreenShot-Detailed.jpg
Binary file not shown.
Binary file modified graphics/ScreenShot-Trending.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/ScreenShot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions 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.9</version>
<version>5.0.10</version>
<packaging>jar</packaging>

<name>quoter</name>
Expand Down Expand Up @@ -229,7 +229,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0-M1</version>
<version>5.10.0-RC1</version>
<scope>test</scope>
</dependency>
</dependencies>
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.9'
version: '5.0.10'
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
6 changes: 6 additions & 0 deletions src/main/java/org/fross/quoter/CountDownBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
import org.fusesource.jansi.Ansi;

public class CountDownBar extends Thread {
private int countDownOrig = 30;
private int countDown = 30;

// Constructor: Sets the time for the count down in seconds
public CountDownBar(int sec) {
this.countDownOrig = sec;
this.countDown = sec;
}

Expand Down Expand Up @@ -75,5 +77,9 @@ public void run() {
this.interrupt();

}

public void reset() {
this.countDown = this.countDownOrig;
}

}
39 changes: 32 additions & 7 deletions src/main/java/org/fross/quoter/QuoteConsoleOutput.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.fross.quoter;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Iterator;

import org.fross.library.Output;
Expand Down Expand Up @@ -233,22 +238,42 @@ public void invokeSymbolOutput(FileExporter exporter) {
}

// Display the open/closed status of the market
Output.printColor(Ansi.Color.CYAN, "\nThe US index markets are currently: ");
Output.printColor(Ansi.Color.CYAN, "\nThe US index markets are currently: ");
if (Index.marketOpen == true) {
Output.printColorln(Ansi.Color.YELLOW, "OPEN");
} else {
Output.printColorln(Ansi.Color.YELLOW, "CLOSED");
}

// Remove the periods from a.m. or p.m.
// Convert to local time & time zone
if (!timeStamp.isEmpty()) {
timeStamp = timeStamp.replaceAll(" [Pp]\\.[Mm]\\.", "pm");
timeStamp = timeStamp.replaceAll(" [Aa]\\.[Mm]\\.", "am");
} else {
timeStamp = "--";
try {
// Remove the periods from a.m. & p.m. Also make them upper case required by the formatter
if (!timeStamp.isEmpty()) {
timeStamp = timeStamp.replaceAll(" [Pp]\\.[Mm]\\.", "PM");
timeStamp = timeStamp.replaceAll(" [Aa]\\.[Mm]\\.", "AM");
} else {
timeStamp = "--";
throw new DateTimeParseException(null, null, 0);
}

// Parse the time stamp into a LocalDateTime object & set the to the Eastern time zone
LocalDateTime ldt = LocalDateTime.parse(timeStamp, DateTimeFormatter.ofPattern("MMM dd yyyy h:mma"));
ZonedDateTime zdtSrc = ldt.atZone(ZoneId.of("America/New_York"));

// Get local time zone for this JVM from the JVM system properties
ZoneId destTimeZone = ZoneId.of(System.getProperty("user.timezone"));
ZonedDateTime zdtDest = zdtSrc.withZoneSameInstant(destTimeZone);

// Build the updated time stamp
timeStamp = zdtDest.format(DateTimeFormatter.ofPattern("MMM dd yyyy hh:mm a z (O)"));

} catch (DateTimeParseException ex) {
// Take no action and just use the original timeStamp as received from the financial website
}
}

Output.printColorln(Ansi.Color.CYAN, "Data as of " + timeStamp + " Eastern. Quotes are delayed.");
Output.printColorln(Ansi.Color.CYAN, "Data as of " + timeStamp + ". Quotes are delayed.");

// Display trending data if -t was provided and there is at least one valid symbol
if (cli.clTrend == true) {
Expand Down

0 comments on commit ebcab1b

Please sign in to comment.