set timezone for memo
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Steven Polley 2023-11-13 16:28:00 -07:00
parent f3a7df7de9
commit 77e467071b
2 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import (
"io"
"net/http"
"net/url"
"os"
"time"
)
@ -22,6 +23,7 @@ type Client struct {
BudgetID string
httpClient *http.Client
transport *http.Transport
loc *time.Location
}
// Send an HTTP GET request, and return the processed response
@ -130,12 +132,18 @@ func NewClient(budgetID, bearerToken string) (*Client, error) {
Transport: transport,
}
loc, err := time.LoadLocation(os.Getenv("TZ"))
if err != nil {
return nil, fmt.Errorf("failed to load timezone location '%s': %v", os.Getenv("TZ"), err)
}
// Create a new client
c := &Client{
BudgetID: budgetID,
BearerToken: bearerToken,
httpClient: client,
transport: transport,
loc: loc,
}
return c, nil
}

View File

@ -93,7 +93,7 @@ func (c *Client) createTodayYNABCapitalGainsTransaction(accountID string, amount
transaction.Transaction.Cleared = "cleared"
transaction.Transaction.Approved = true
transaction.Transaction.PayeeName = "Capital Gains or Losses"
transaction.Transaction.Memo = fmt.Sprintf("Quoted at: %s", time.Now().Format("2006-01-02 15:04:05"))
transaction.Transaction.Memo = fmt.Sprintf("Quoted at: %s", time.Now().In(c.loc).Format("2006-01-02 15:04:05"))
response := &Transaction{}
@ -114,7 +114,7 @@ func (c *Client) updateTodayYNABCapitalGainsTransaction(accountID string, transa
transaction.Transaction.Cleared = "cleared"
transaction.Transaction.Approved = true
transaction.Transaction.PayeeName = "Capital Gains or Losses"
transaction.Transaction.Memo = fmt.Sprintf("Quoted at: %s", time.Now().Format("2006-01-02 15:04:05"))
transaction.Transaction.Memo = fmt.Sprintf("Quoted at: %s", time.Now().In(c.loc).Format("2006-01-02 15:04:05"))
response := &Transaction{}