Show formatted date for fee expiry

This commit is contained in:
jholdstock 2021-05-08 09:45:37 +01:00 committed by Jamie Holdstock
parent b5a65a9e78
commit 3a97c9214b
4 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,7 @@
package webapi package webapi
import "time"
func addressURL(blockExplorerURL string) func(string) string { func addressURL(blockExplorerURL string) func(string) string {
return func(addr string) string { return func(addr string) string {
return blockExplorerURL + "/address/" + addr return blockExplorerURL + "/address/" + addr
@ -11,3 +13,7 @@ func txURL(blockExplorerURL string) func(string) string {
return blockExplorerURL + "/tx/" + txID return blockExplorerURL + "/tx/" + txID
} }
} }
func dateTime(t int64) string {
return time.Unix(t, 0).Format("2 Jan 2006 15:04:05")
}

View File

@ -55,7 +55,7 @@ func updateVSPStats(db *database.VspDatabase, cfg Config) error {
Revoked: revoked, Revoked: revoked,
VSPFee: cfg.VSPFee, VSPFee: cfg.VSPFee,
Network: cfg.NetParams.Name, Network: cfg.NetParams.Name,
UpdateTime: time.Now().Format("Mon Jan _2 15:04:05 2006"), UpdateTime: dateTime(time.Now().Unix()),
SupportEmail: cfg.SupportEmail, SupportEmail: cfg.SupportEmail,
VspClosed: cfg.VspClosed, VspClosed: cfg.VspClosed,
Debug: cfg.Debug, Debug: cfg.Debug,

View File

@ -125,7 +125,7 @@
</tr> </tr>
<tr> <tr>
<th>Fee Expiration</th> <th>Fee Expiration</th>
<td>{{ .Ticket.FeeExpiration }}</td> <td>{{ .Ticket.FeeExpiration }} ({{ dateTime .Ticket.FeeExpiration }}) </td>
</tr> </tr>
<tr> <tr>
<th>Confirmed</th> <th>Confirmed</th>

View File

@ -179,8 +179,8 @@ func router(debugMode bool, cookieSecret []byte, dcrd rpc.DcrdConnect, wallets r
// Add custom functions for use in templates. // Add custom functions for use in templates.
router.SetFuncMap(template.FuncMap{ router.SetFuncMap(template.FuncMap{
"txURL": txURL(cfg.BlockExplorerURL), "txURL": txURL(cfg.BlockExplorerURL),
"blockURL": blockURL(cfg.BlockExplorerURL),
"addressURL": addressURL(cfg.BlockExplorerURL), "addressURL": addressURL(cfg.BlockExplorerURL),
"dateTime": dateTime,
}) })
router.LoadHTMLGlob("webapi/templates/*.html") router.LoadHTMLGlob("webapi/templates/*.html")