Server-rendered <time datetime> and JSON-LD dates ignore the site time zone (server-local wall clock labeled as UTC)
I maintainer di solito rispondono entro 6 giorni
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 78/100
Direzione di ricerca
Start with internal/base/server/http_funcmap.go, especially timeFormatISO and translatorTimeFormat, then inspect JSON-LD date construction in internal/controller/template_controller.go and the time-zone behavior in pkg/day. Reproduce the examples using Asia/Tokyo and America/New_York; done means HTML dates, JSON-LD dates, and year-boundary decisions respect the configured zone, with the stated fallback for unknown zones.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
The server-rendered <time datetime="..."> attributes and the question-page JSON-LD dates ignore the site-configured time zone and mislabel the instant:
-
The
timeFormatISOtemplate func (internal/base/server/http_funcmap.go) callstime.LoadLocation(tz)but discards the loaded location — the exact pattern fixed forday.Formatin #1659 — and then formats the timestamp in the server's local zone with the layout"2006-01-02T15:04:05.000Z", where the trailingZis a literal, not an ISO zone token. Every rendered<time datetime=...>(question detail ×4, comment, question list, tag detail) therefore carries the server-local wall clock labeled as UTC. -
The JSON-LD
DateCreatedfields intemplate_controller.go(jsonLD.MainEntity.DateCreated, accepted/suggested answer items) are built withtime.Unix(...)in the server-local zone and serialized with that offset, so the structured SEO data carries the deployment's zone instead of the site's configured one (siteInfo.Interface.TimeZone, which the templates already receive and forward correctly). -
The year-boundary decision inside
translatorTimeFormat(time.Unix(timestamp, 0).Format("2006") == time.Unix(now, 0).Format("2006")) compares calendar years in the server zone, not the display zone, so a post rendered shortly after New Year in the site zone can drop the year (or keep it) incorrectly whenever the two zones disagree.
Steps to reproduce
Executed against current master (standalone test invoking the real funcMap, process started with TZ=Asia/Shanghai):
timeFormatISO("Asia/Tokyo", 1700000000) = 2023-11-15T06:13:20.000Z
correct would be = 2023-11-15T07:13:20.000+09:00
timeFormatISO("America/New_York", 1700000000) = 2023-11-15T06:13:20.000Z
correct would be = 2023-11-14T17:13:20.000-05:00
1700000000 is 2023-11-14T22:13:20Z. Both requested zones are ignored, and the UTC+8 wall clock is labeled Z. The same values feed every <time datetime="..."> in the rendered HTML and are indexed from there.
Expected behavior
timeFormatISO(tz, ts)renders the instant intz(falling back to the server zone for empty/unknown zones, the same semantics #1659 established forday.Format) with a real ISO-8601 zone marker (+09:00, orZonly when the zone is UTC).- The JSON-LD dates use the site's configured zone.
- The relative/absolute rendering decisions (same-year check) are made in the display zone.
Specifications
- Version: current
master(verified on a tarball of master, 2026-11-13) - Platform: linux/amd64, Go 1.24 module
- Subsystem:
internal/base/server/http_funcmap.go,internal/controller/template_controller.go,pkg/day
Possible Solution
Follow the semantics #1659 established: keep one zone-aware helper in pkg/day (e.g. FormatISO) used by timeFormatISO, drop the dead LoadLocation calls, make the same-year decision in the display zone, and render the JSON-LD time.Time values with .In(siteLoc). Happy to send a PR with regression tests covering the zones above plus the unknown-zone fallback.
- Lingua principale
- Go
- Stelle
- 15.7k
- Fork
- 1.4k
- Merge medio
- 9g 6h
- PR unite (30g)
- 8
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/answer
-
Hardening: cap the invite_user list size in UpdateQuestionInviteUser to bound notification fan-outForse già presa @TastyHeadphones l’ha presa 47 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/answer#1617 · 1 commento ·
I maintainer di solito rispondono entro 6 giorni
-
Admin AI settings silently reset the assistant prompt, which cannot be edited in the UIForse già presa @Andy-Sverdlov-LucaNet l’ha presa 63 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 6 giorni
-
🌐 Contribute a translationAperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 75/100
apache/answer#158 · 16 commenti ·
I maintainer di solito rispondono entro 6 giorni
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
I maintainer di solito rispondono entro 6 giorni
-
Searching user:<username> returns the wrong posts when the username starts with "me"Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di apache/answer
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
bazel-contrib/rules_go#4784 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Уязвимые компоненты в GoAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
POSIdev-community/aictl#40 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
nebari-dev/nebari-infrastructure-core#774 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
oracle/terraform-provider-oci#2662 ·