Documentation
¶
Overview ¶
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.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendDate ¶
AppendDate appends t's date. The fields are read from t in its own location.
func AppendTimestamp ¶
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.
Types ¶
This section is empty.