Skip to content

Commit

Permalink
Show formatted date for fee expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
jholdstock committed May 13, 2021
1 parent b5a65a9 commit 3a97c92
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions webapi/formatting.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package webapi

import "time"

func addressURL(blockExplorerURL string) func(string) string {
return func(addr string) string {
return blockExplorerURL + "/address/" + addr
Expand All @@ -11,3 +13,7 @@ func txURL(blockExplorerURL string) func(string) string {
return blockExplorerURL + "/tx/" + txID
}
}

func dateTime(t int64) string {
return time.Unix(t, 0).Format("2 Jan 2006 15:04:05")
}
2 changes: 1 addition & 1 deletion webapi/homepage.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func updateVSPStats(db *database.VspDatabase, cfg Config) error {
Revoked: revoked,
VSPFee: cfg.VSPFee,
Network: cfg.NetParams.Name,
UpdateTime: time.Now().Format("Mon Jan _2 15:04:05 2006"),
UpdateTime: dateTime(time.Now().Unix()),
SupportEmail: cfg.SupportEmail,
VspClosed: cfg.VspClosed,
Debug: cfg.Debug,
Expand Down
2 changes: 1 addition & 1 deletion webapi/templates/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ <h1>Search Result</h1>
</tr>
<tr>
<th>Fee Expiration</th>
<td>{{ .Ticket.FeeExpiration }}</td>
<td>{{ .Ticket.FeeExpiration }} ({{ dateTime .Ticket.FeeExpiration }}) </td>
</tr>
<tr>
<th>Confirmed</th>
Expand Down
2 changes: 1 addition & 1 deletion webapi/webapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ func router(debugMode bool, cookieSecret []byte, dcrd rpc.DcrdConnect, wallets r
// Add custom functions for use in templates.
router.SetFuncMap(template.FuncMap{
"txURL": txURL(cfg.BlockExplorerURL),
"blockURL": blockURL(cfg.BlockExplorerURL),
"addressURL": addressURL(cfg.BlockExplorerURL),
"dateTime": dateTime,
})

router.LoadHTMLGlob("webapi/templates/*.html")
Expand Down

0 comments on commit 3a97c92

Please sign in to comment.