MCPcopy Create free account
hub / github.com/PostHog/duckgres / decodeDate

Function decodeDate

server/types.go:957–965  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

955}
956
957func decodeDate(data []byte) (time.Time, error) {
958 if len(data) < 4 {
959 return time.Time{}, fmt.Errorf("insufficient data for date: got %d bytes, need 4", len(data))
960 }
961 // Days since PostgreSQL epoch (2000-01-01)
962 days := int32(binary.BigEndian.Uint32(data))
963 pgEpoch := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
964 return pgEpoch.AddDate(0, 0, int(days)), nil
965}
966
967func decodeTimestamp(data []byte) (time.Time, error) {
968 if len(data) < 8 {

Callers 3

TestDecodeDateFunction · 0.85
decodeBinaryCopyFunction · 0.85
decodeBinaryFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestDecodeDateFunction · 0.68