Pg: Add "time" type, change default format of "date" type but support "$date_str"

Using a consistent numeric interpretation for timestamps, dates and
times simplifies a bunch of operations. It certainly simplifies
conversion between the Postgres formats.
This commit is contained in:
Yorhel 2025-02-28 13:03:00 +01:00
parent 0734bc4991
commit baf0f90bd5
3 changed files with 78 additions and 9 deletions

View file

@ -638,8 +638,24 @@ stored in a 64-bit integer. If you prefer that, use:
=item date
Converted between strings in C<YYYY-MM-DD> format. Postgres accepts a bunch of
alternative date formats, this module does not.
Converted between seconds since Unix epoch as an integer, with the time fixed
at C<00:00:00 UTC>. When used as bind parameter, the time part is truncated.
This format makes for easy comparison with other timestamps, but if you prefer
to work with strings in the C<YYYY-MM-DD> format instead, use:
$conn->set_type(date => '$date_str');
Postgres accepts a bunch of alternative date formats for bind paramaters, this
module does not.
=item time
Converted between floating point seconds since C<00:00:00>, supporting
microsecond precision. This format allows for easy comparison against Unix
timestamps (time of day = C<$timestamp % 86400>) and can be added to an integer
date value to form a complete timestamp.
(There's no support for the string format yet)
=item json / jsonb
@ -689,7 +705,7 @@ can work around.
=item money
=item time / timetz
=item timetz
=item bit / varbit