|
|
@@ -4,6 +4,7 @@ import (
|
|
|
"fmt"
|
|
|
"os"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
|
|
|
"github.com/joho/godotenv"
|
|
|
"github.com/spf13/cobra"
|
|
|
@@ -63,6 +64,7 @@ func formatGames(games []game.Game, mode string) string {
|
|
|
// One table per store keeps columns uniform (dates only for epic).
|
|
|
b.WriteString("| Game | Store | Price | Period |\n")
|
|
|
b.WriteString("|---|---|---|---|\n")
|
|
|
+ loc := outputLocation("CHEAPO_CHATTO_OUTPUT_TIMEZONE", time.Local)
|
|
|
for _, g := range games {
|
|
|
dateFmt := os.Getenv("CHEAPO_CHATTO_OUTPUT_DATE_FORMAT")
|
|
|
if dateFmt == "" {
|
|
|
@@ -71,10 +73,10 @@ func formatGames(games []game.Game, mode string) string {
|
|
|
period := "—"
|
|
|
if g.Kind == "upcoming" && !g.StartDate.IsZero() && !g.EndDate.IsZero() {
|
|
|
period = fmt.Sprintf("from %s, until %s",
|
|
|
- g.StartDate.Local().Format(dateFmt),
|
|
|
- g.EndDate.Local().Format(dateFmt))
|
|
|
+ g.StartDate.In(loc).Format(dateFmt),
|
|
|
+ g.EndDate.In(loc).Format(dateFmt))
|
|
|
} else if !g.EndDate.IsZero() {
|
|
|
- period = "until " + g.EndDate.Local().Format(dateFmt)
|
|
|
+ period = "until " + g.EndDate.In(loc).Format(dateFmt)
|
|
|
}
|
|
|
fmt.Fprintf(&b, "| **%s** | [%s](%s) | %s | %s |\n",
|
|
|
escapePipe(g.Title), g.Store, g.URL, priceCell(g), period)
|