Show last update check time in local timezone

This commit is contained in:
Matt Baer 2020-02-15 11:57:55 -05:00
parent 68e992a55e
commit 48ca695c46
2 changed files with 10 additions and 1 deletions

View File

@ -584,6 +584,7 @@ func handleViewAdminUpdates(app *App, u *User, w http.ResponseWriter, r *http.Re
p := struct { p := struct {
*UserPage *UserPage
LastChecked string LastChecked string
LastChecked8601 string
LatestVersion string LatestVersion string
LatestReleaseNotesURL string LatestReleaseNotesURL string
UpdateAvailable bool UpdateAvailable bool
@ -592,6 +593,7 @@ func handleViewAdminUpdates(app *App, u *User, w http.ResponseWriter, r *http.Re
} }
if app.cfg.App.UpdateChecks { if app.cfg.App.UpdateChecks {
p.LastChecked = app.updates.lastCheck.Format("January 2, 2006, 3:04 PM") p.LastChecked = app.updates.lastCheck.Format("January 2, 2006, 3:04 PM")
p.LastChecked8601 = app.updates.lastCheck.Format("2006-01-02T15:04:05Z")
p.LatestVersion = app.updates.LatestVersion() p.LatestVersion = app.updates.LatestVersion()
p.LatestReleaseNotesURL = app.updates.ReleaseNotesURL() p.LatestReleaseNotesURL = app.updates.ReleaseNotesURL()
p.UpdateAvailable = app.updates.AreAvailable() p.UpdateAvailable = app.updates.AreAvailable()

View File

@ -15,7 +15,14 @@
For details on features, bug fixes or notes on upgrading, <a href="{{.LatestReleaseNotesURL}}">read the release notes</a>. For details on features, bug fixes or notes on upgrading, <a href="{{.LatestReleaseNotesURL}}">read the release notes</a>.
</section> </section>
{{end}} {{end}}
<p>Last checked at: {{.LastChecked}}. <a href="/admin/updates?check=now">Check now</a>.</p> <p>Last checked at: <time class="dt-published" datetime="{{.LastChecked8601}}">{{.LastChecked}}</time>. <a href="/admin/updates?check=now">Check now</a>.</p>
<script>
// Code modified from /js/localdate.js
var displayEl = document.querySelector("time");
var d = new Date(displayEl.getAttribute("datetime"));
displayEl.textContent = d.toLocaleDateString(navigator.language || "en-US", { dateStyle: 'long', timeStyle: 'short' });
</script>
{{template "footer" .}} {{template "footer" .}}