]> granicus.if.org Git - php/blob
24b0094c9e
[php] /
1 --TEST--
2 Test date_parse() function : error conditions
3 --FILE--
4 <?php
5 /* Prototype  : array date_parse  ( string $date  )
6  * Description: Returns associative array with detailed info about given date.
7  * Source code: ext/date/php_date.c
8  */
9
10 //Set the default time zone
11 date_default_timezone_set("Europe/London");
12
13 echo "*** Testing date_parse() : error conditions ***\n";
14
15 echo "\n-- Testing date_parse() function with unexpected characters in \$date argument --\n";
16 $invalid_date = "2OO9-02--27 10:00?00.5";
17 var_dump( date_parse($invalid_date) );
18
19 ?>
20 --EXPECTF--
21 *** Testing date_parse() : error conditions ***
22
23 -- Testing date_parse() function with unexpected characters in $date argument --
24 array(13) {
25   ["year"]=>
26   bool(false)
27   ["month"]=>
28   bool(false)
29   ["day"]=>
30   bool(false)
31   ["hour"]=>
32   int(10)
33   ["minute"]=>
34   int(0)
35   ["second"]=>
36   int(0)
37   ["fraction"]=>
38   float(0)
39   ["warning_count"]=>
40   int(1)
41   ["warnings"]=>
42   array(1) {
43     [4]=>
44     string(29) "Double timezone specification"
45   }
46   ["error_count"]=>
47   int(7)
48   ["errors"]=>
49   array(7) {
50     [0]=>
51     string(20) "Unexpected character"
52     [1]=>
53     string(47) "The timezone could not be found in the database"
54     [3]=>
55     string(20) "Unexpected character"
56     [7]=>
57     string(20) "Unexpected character"
58     [8]=>
59     string(29) "Double timezone specification"
60     [17]=>
61     string(20) "Unexpected character"
62     [18]=>
63     string(25) "Double time specification"
64   }
65   ["is_localtime"]=>
66   bool(true)
67   ["zone_type"]=>
68   int(0)
69 }