MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / PGWireFormatTimeTZ

Function PGWireFormatTimeTZ

pkg/sql/sem/tree/pgwire_encode.go:323–340  ·  view source on GitHub ↗

PGWireFormatTimeTZ formats t into a format lib/pq understands, appending to the provided tmp buffer and reallocating if needed. The function will then return the resulting buffer.

(t timetz.TimeTZ, tmp []byte)

Source from the content-addressed store, hash-verified

321// provided tmp buffer and reallocating if needed. The function will then return
322// the resulting buffer.
323func PGWireFormatTimeTZ(t timetz.TimeTZ, tmp []byte) []byte {
324 format := PGTimeTZFormat
325 if t.OffsetSecs%60 != 0 {
326 format += ":00:00"
327 } else if t.OffsetSecs%3600 != 0 {
328 format += ":00"
329 }
330 ret := t.ToTime().AppendFormat(tmp, format)
331 // time.Time's AppendFormat does not recognize 2400, so special case it accordingly.
332 if t.TimeOfDay == timeofday.Time2400 {
333 // It instead reads 00:00:00. Replace that text.
334 var newRet []byte
335 newRet = append(newRet, PGTime2400Format...)
336 newRet = append(newRet, ret[len(PGTime2400Format):]...)
337 ret = newRet
338 }
339 return ret
340}
341
342// PGWireFormatTimestamp formats t into a format lib/pq understands.
343// If offset is not nil, it will not display the timezone offset.

Callers 1

FormatMethod · 0.85

Calls 2

AppendFormatMethod · 0.45
ToTimeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…