From 3a97c9214b4d36aab0068298ea45ff3177f15cfb Mon Sep 17 00:00:00 2001 From: jholdstock Date: Sat, 8 May 2021 09:45:37 +0100 Subject: [PATCH] Show formatted date for fee expiry --- webapi/formatting.go | 6 ++++++ webapi/homepage.go | 2 +- webapi/templates/admin.html | 2 +- webapi/webapi.go | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/webapi/formatting.go b/webapi/formatting.go index 1cbe120..b3489c8 100644 --- a/webapi/formatting.go +++ b/webapi/formatting.go @@ -1,5 +1,7 @@ package webapi +import "time" + func addressURL(blockExplorerURL string) func(string) string { return func(addr string) string { return blockExplorerURL + "/address/" + addr @@ -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") +} diff --git a/webapi/homepage.go b/webapi/homepage.go index b3168f0..626f82b 100644 --- a/webapi/homepage.go +++ b/webapi/homepage.go @@ -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, diff --git a/webapi/templates/admin.html b/webapi/templates/admin.html index 35da78d..d7f7191 100644 --- a/webapi/templates/admin.html +++ b/webapi/templates/admin.html @@ -125,7 +125,7 @@ Fee Expiration - {{ .Ticket.FeeExpiration }} + {{ .Ticket.FeeExpiration }} ({{ dateTime .Ticket.FeeExpiration }}) Confirmed diff --git a/webapi/webapi.go b/webapi/webapi.go index 8e71609..9aecd3b 100644 --- a/webapi/webapi.go +++ b/webapi/webapi.go @@ -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")