From f94347864e49b3ab56a126458bac9d999e1286d2 Mon Sep 17 00:00:00 2001 From: tobi Date: Sun, 2 Mar 2025 11:01:33 +0100 Subject: [PATCH] poke --- internal/router/template.go | 25 ------------------------- web/source/frontend/index.js | 21 ++++++++++++--------- web/template/status_attributes.tmpl | 2 +- 3 files changed, 13 insertions(+), 35 deletions(-) diff --git a/internal/router/template.go b/internal/router/template.go index 981c3fcf4..70d87add1 100644 --- a/internal/router/template.go +++ b/internal/router/template.go @@ -26,7 +26,6 @@ import ( "reflect" "regexp" "strings" - "time" "unsafe" "github.com/gin-gonic/gin" @@ -128,7 +127,6 @@ var funcMap = template.FuncMap{ "oddOrEven": oddOrEven, "subtract": subtract, "timestampPrecise": timestampPrecise, - "timestamp": timestamp, "timestampVague": timestampVague, "visibilityIcon": visibilityIcon, } @@ -174,29 +172,6 @@ const ( badTimestamp = "bad timestamp" ) -func timestamp(stamp string) string { - t, err := util.ParseISO8601(stamp) - if err != nil { - log.Errorf(nil, "error parsing timestamp %s: %s", stamp, err) - return badTimestamp - } - - t = t.Local() - - tYear, tMonth, tDay := t.Date() - now := time.Now() - currentYear, currentMonth, currentDay := now.Date() - - switch { - case tYear == currentYear && tMonth == currentMonth && tDay == currentDay: - return "Today, " + t.Format(justTime) - case tYear == currentYear: - return t.Format(dateTime) - default: - return t.Format(dateYear) - } -} - func timestampPrecise(stamp string) string { t, err := util.ParseISO8601(stamp) if err != nil { diff --git a/web/source/frontend/index.js b/web/source/frontend/index.js index 9c7183a58..310d149ed 100644 --- a/web/source/frontend/index.js +++ b/web/source/frontend/index.js @@ -185,16 +185,19 @@ Array.from(document.getElementsByClassName("plyr-video")).forEach((video) => { Array.from(document.getElementsByTagName('time')).forEach(timeTag => { const datetime = timeTag.getAttribute('datetime'); const currentText = timeTag.textContent.trim(); - // Only format if current text contains precise time + // Only format if current text contains precise time. if (currentText.match(/\d{2}:\d{2}/)) { const date = new Date(datetime); - timeTag.textContent = date.toLocaleString(undefined, { - year: 'numeric', - month: 'short', - day: '2-digit', - hour: '2-digit', - minute: '2-digit', - hour12: false - }); + timeTag.textContent = date.toLocaleString( + undefined, + { + year: 'numeric', + month: 'short', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + hour12: false + }, + ); } }); diff --git a/web/template/status_attributes.tmpl b/web/template/status_attributes.tmpl index 92659b6b2..b93db6259 100644 --- a/web/template/status_attributes.tmpl +++ b/web/template/status_attributes.tmpl @@ -18,7 +18,7 @@ */ -}} {{- define "ariaLabel" -}} -@{{ .Account.Acct -}}, {{ timestamp .CreatedAt -}} +@{{ .Account.Acct -}}, {{ .CreatedAt | timestampPrecise -}} {{- if .LanguageTag -}} , language {{ .LanguageTag.DisplayStr -}} {{- end -}}