MCPcopy Create free account
hub / github.com/PatchMon/PatchMon / setUTCTimeZone

Function setUTCTimeZone

server-source-code/internal/database/db.go:191–199  ·  view source on GitHub ↗

setUTCTimeZone pins the session TimeZone to UTC for every connection in the pool. Our created_at/updated_at columns are TIMESTAMP (without time zone). Postgres converts NOW()/CURRENT_TIMESTAMP (timestamptz) into the session's local wall clock when inserting into such columns, while pgx reads them ba

(poolCfg *pgxpool.Config)

Source from the content-addressed store, hash-verified

189// Forcing the session to UTC keeps store and read consistent so relative-time
190// formatting on the frontend doesn't drift by the DB host's TZ offset.
191func setUTCTimeZone(poolCfg *pgxpool.Config) {
192 if poolCfg == nil || poolCfg.ConnConfig == nil {
193 return
194 }
195 if poolCfg.ConnConfig.RuntimeParams == nil {
196 poolCfg.ConnConfig.RuntimeParams = map[string]string{}
197 }
198 poolCfg.ConnConfig.RuntimeParams["TimeZone"] = "UTC"
199}

Callers 3

NewPoolFunction · 0.85
NewDBFunction · 0.85
NewFromURLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected