File tree Expand file tree Collapse file tree 6 files changed +113
-29
lines changed Expand file tree Collapse file tree 6 files changed +113
-29
lines changed Original file line number Diff line number Diff line change @@ -34,3 +34,28 @@ function test_ibase_trans_014_015() {
3434 var_dump (ibase_close ());
3535 var_dump (ibase_close ($ x ));
3636}
37+
38+ function test_time_unixtime (): void {
39+ ini_set ("ibase.timeformat " , "%H:%M:%S " );
40+ ibase_query ("CREATE TABLE TTEST (
41+ ID INTEGER,
42+ T1 TIME DEFAULT '15:45:59',
43+ T2 TIMESTAMP DEFAULT '2025-11-06 15:45:59'
44+ ) " );
45+ ibase_commit ();
46+ ibase_query ("INSERT INTO TTEST (ID) VALUES (1) " );
47+ dump_table_rows ("TTEST " );
48+ dump_table_rows ("TTEST " , null , IBASE_UNIXTIME );
49+ }
50+
51+ function test_time_tz_unixtime (): void {
52+ ibase_query ("CREATE TABLE TTEST (
53+ ID INTEGER,
54+ T1 TIME WITH TIME ZONE DEFAULT '15:45:59 Europe/Riga',
55+ T2 TIMESTAMP WITH TIME ZONE DEFAULT '2025-11-06 15:45:59 Europe/Riga'
56+ ) " );
57+ ibase_commit ();
58+ ibase_query ("INSERT INTO TTEST (ID) VALUES (1) " );
59+ dump_table_rows ("TTEST " );
60+ dump_table_rows ("TTEST " , null , IBASE_UNIXTIME );
61+ }
Original file line number Diff line number Diff line change @@ -133,12 +133,12 @@ function skip_if_fb_gte($v) {
133133
134134/** @var float $v */
135135function skip_if_fbclient_lt ($ v ) {
136- if (!function_exists ("ibase_get_client_version " ))die ("skip Unable to determine Firebird client library version " );
136+ if (!function_exists ("ibase_get_client_version " ))die ("skip Firebird client library version (undefined) < $ v " );
137137 if (($ cv = ibase_get_client_version ()) < $ v )die ("skip Firebird client library version $ cv < $ v " );
138138}
139139
140140function skip_if_ext_lt (int $ v ): void {
141- if (!defined ('IBASE_VER ' ))die ("Skip IBASE_VER not defined " );
141+ if (!defined ('IBASE_VER ' ))die ("Skip IBASE_VER ( not defined) < $ v " );
142142 if (IBASE_VER < $ v )die ("Skip IBASE_VER " .IBASE_VER ." < $ v " );
143143}
144144
Original file line number Diff line number Diff line change 11--TEST--
2- Test unixtimestamp
2+ IBASE_UNIXTIME: return negative unix timestamp (old behaviour) for TIME fields
33--SKIPIF--
44<?php
55include ("skipif.inc " );
6+
7+ // See also: tests/time_003.phpt
8+ skip_if_ext_gte (61 );
9+
610?>
711--FILE--
812<?php
913
1014require ("interbase.inc " );
15+ require ("common.inc " );
1116ibase_connect ($ test_base );
12-
13- (function (){
14- ibase_query ("CREATE TABLE TTEST (
15- ID INTEGER,
16- T1 TIME DEFAULT '15:45:59',
17- T2 TIMESTAMP DEFAULT '2025-11-06 15:45:59'
18- ) " );
19- ibase_commit ();
20- ibase_query ("INSERT INTO TTEST (ID) VALUES (1) " );
21- dump_table_rows ("TTEST " );
22- dump_table_rows ("TTEST " , null , IBASE_UNIXTIME );
23- })();
17+ test_time_unixtime ();
2418
2519?>
2620--EXPECTF--
Original file line number Diff line number Diff line change 11--TEST--
2- Test unixtimestamp
2+ IBASE_UNIXTIME: return negative unix timestamp (old behaviour) for TIME_TZ fields
33--SKIPIF--
44<?php
55include ("skipif.inc " );
6- skip_if_fb_lt (4 ) || skip_if_fbclient_lt (4 );
6+ // See also: tests/time_004.phpt
7+ skip_if_ext_gte (61 );
8+ skip_if_fb_lt (4 );
9+ skip_if_fbclient_lt (4 );
710?>
811--FILE--
912<?php
1013
1114require ("interbase.inc " );
15+ require ("common.inc " );
1216ibase_connect ($ test_base );
13-
14- (function (){
15- ibase_query ("CREATE TABLE TTEST (
16- ID INTEGER,
17- T1 TIME WITH TIME ZONE DEFAULT '15:45:59 Europe/Riga',
18- T2 TIMESTAMP WITH TIME ZONE DEFAULT '2025-11-06 15:45:59 Europe/Riga'
19- ) " );
20- ibase_commit ();
21- ibase_query ("INSERT INTO TTEST (ID) VALUES (1) " );
22- dump_table_rows ("TTEST " );
23- dump_table_rows ("TTEST " , null , IBASE_UNIXTIME );
24- })();
17+ test_time_tz_unixtime ();
2518
2619?>
2720--EXPECTF--
Original file line number Diff line number Diff line change 1+ --TEST--
2+ IBASE_UNIXTIME: ignore IBASE_UNIXTIME flag for TIME fields
3+ --SKIPIF--
4+ <?php
5+ include ("skipif.inc " );
6+
7+ // See also: tests/time_001.phpt
8+ skip_if_ext_lt (61 );
9+
10+ ?>
11+ --FILE--
12+ <?php
13+
14+ require ("interbase.inc " );
15+ require ("common.inc " );
16+ ibase_connect ($ test_base );
17+ test_time_unixtime ();
18+
19+ ?>
20+ --EXPECTF--
21+ array(3) {
22+ ["ID"]=>
23+ int(1)
24+ ["T1"]=>
25+ string(8) "15:45:59"
26+ ["T2"]=>
27+ string(19) "2025-11-06 15:45:59"
28+ }
29+ array(3) {
30+ ["ID"]=>
31+ int(1)
32+ ["T1"]=>
33+ string(8) "15:45:59"
34+ ["T2"]=>
35+ int(1762436759)
36+ }
Original file line number Diff line number Diff line change 1+ --TEST--
2+ IBASE_UNIXTIME: ignore IBASE_UNIXTIME flag for TIME_TZ fields
3+ --SKIPIF--
4+ <?php
5+ include ("skipif.inc " );
6+ // See also: tests/time_002.phpt
7+ skip_if_ext_lt (61 );
8+ skip_if_fb_lt (4 );
9+ skip_if_fbclient_lt (4 );
10+ ?>
11+ --FILE--
12+ <?php
13+
14+ require ("interbase.inc " );
15+ require ("common.inc " );
16+ ibase_connect ($ test_base );
17+ test_time_tz_unixtime ();
18+
19+ ?>
20+ --EXPECTF--
21+ array(3) {
22+ ["ID"]=>
23+ int(1)
24+ ["T1"]=>
25+ string(20) "15:45:59 Europe/Riga"
26+ ["T2"]=>
27+ string(31) "2025-11-06 15:45:59 Europe/Riga"
28+ }
29+ array(3) {
30+ ["ID"]=>
31+ int(1)
32+ ["T1"]=>
33+ string(20) "15:45:59 Europe/Riga"
34+ ["T2"]=>
35+ int(1762436759)
36+ }
You can’t perform that action at this time.
0 commit comments