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:
parent
0734bc4991
commit
baf0f90bd5
3 changed files with 78 additions and 9 deletions
14
t/pgtypes.t
14
t/pgtypes.t
|
|
@ -116,6 +116,13 @@ v timestamptz => 1740133814.705915, undef, '2025-02-21 10:30:14.705915+00';
|
|||
v timestamp => 0, undef, '1970-01-01 00:00:00';
|
||||
v timestamp => 1740133814.705915, undef, '2025-02-21 10:30:14.705915';
|
||||
|
||||
v date => 0, undef, '1970-01-01';
|
||||
v date => 915753600, undef, '1999-01-08';
|
||||
v date => 1740355200, undef, '2025-02-24';
|
||||
f date => '';
|
||||
f date => '1970-01-01';
|
||||
|
||||
$conn->set_type(date => '$date_str');
|
||||
v date => '1970-01-01';
|
||||
v date => '1999-01-08';
|
||||
v date => '2025-02-24';
|
||||
|
|
@ -124,6 +131,13 @@ f date => '2025-';
|
|||
f date => '2025-02-';
|
||||
f date => '1999-Jan-08';
|
||||
|
||||
v time => 0, undef, '00:00:00';
|
||||
v time => 60.123456, undef, '00:01:00.123456';
|
||||
v time => 3600 * 13 + 43 * 60 + 19 + 0.987654, undef, '13:43:19.987654';
|
||||
f time => '';
|
||||
f time => -1;
|
||||
f time => 86400.1;
|
||||
|
||||
v 'int[]', [], undef, '{}';
|
||||
v 'int[]', [1], undef, '{1}';
|
||||
v 'int[]', [1,-3,undef,3], undef, '{1,-3,NULL,3}';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue