package pgdatetime

Import Path
	github.com/jackc/pgx/v5/internal/pgdatetime (on go.dev)

Dependency Relation
	imports 2 packages, and imported by 2 packages

Involved Source Files Package pgdatetime writes PostgreSQL's ISO date/time text format. The format is the one EncodeDateTime and AppendSeconds produce in src/backend/utils/adt/datetime.c under the default ISO DateStyle: stamp = date [ SP time [ zone ] ] [ " BC" ] date = year "-" 2DIGIT "-" 2DIGIT time = 2DIGIT ":" 2DIGIT ":" 2DIGIT [ "." 1*6DIGIT ] The year is zero-padded to four digits and then grows as wide as it needs, the fractional part is omitted when it is zero and never carries trailing zeros, and " BC" comes last, after any time zone. Go's layout language can express none of those, which is why the format is written out here rather than left to time.Format. This is the only implementation of the format in pgx. pgtype's date, timestamp and timestamptz text encoders and the simple protocol's query sanitizer all go through it, so they cannot drift apart.
Package-Level Functions (total 8, in which 2 are exported)
AppendDate appends t's date. The fields are read from t in its own location.
AppendTimestamp appends t's date and time of day followed by zone, which goes before the era suffix because PostgreSQL writes " BC" last. zone is "Z" for a value already converted to UTC and "" for a type that carries no time zone at all. The fields are read from t in its own location, so a caller that wants the UTC instant must convert first. Sub-microsecond precision is discarded, matching the resolution of the wire format.