mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-23 00:16:16 -06:00
poke
This commit is contained in:
parent
ccece64fba
commit
f94347864e
3 changed files with 13 additions and 35 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
*/ -}}
|
||||
|
||||
{{- define "ariaLabel" -}}
|
||||
@{{ .Account.Acct -}}, {{ timestamp .CreatedAt -}}
|
||||
@{{ .Account.Acct -}}, {{ .CreatedAt | timestampPrecise -}}
|
||||
{{- if .LanguageTag -}}
|
||||
, language {{ .LanguageTag.DisplayStr -}}
|
||||
{{- end -}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue