1--TEST--
2datefmt_localtime_code() icu <= 4.2
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
6--FILE--
7<?php
8
9/*
10 * Test for the datefmt_localtime  function
11 */
12
13
14function ut_main()
15{
16	$locale_arr = array (
17		'en_US_CA'
18	);
19
20	$datetype_arr = array (
21                IntlDateFormatter::FULL,
22                IntlDateFormatter::LONG,
23                IntlDateFormatter::MEDIUM,
24                IntlDateFormatter::SHORT,
25                IntlDateFormatter::NONE
26        );
27
28        $res_str = '';
29
30        $datetype_arr = array (
31                IntlDateFormatter::FULL,
32                IntlDateFormatter::LONG,
33                IntlDateFormatter::MEDIUM,
34        );
35
36        $res_str = '';
37
38
39        $text_arr = array (
40                "Thursday, December 18, 1969 8:49:59 AM PST",
41                "June 18, 1969 8:49:59 AM ",
42                "12/18/69 8:49 AM",
43                "19691218 08:49 AM"
44        );
45
46        $fmt1 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::LONG, IntlDateFormatter::LONG);
47        $fmt2 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM);
48        $fmt3 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::FULL, IntlDateFormatter::FULL);
49        $fmt_array  = array(
50                $fmt1 , $fmt2 ,$fmt3
51        );
52        $fmt_desc_array  = array(
53                "DateType::LONG, TimeType::LONG",
54                "DateType::MEDIUM, TimeType::MEDIUM",
55                "DateType::FULL, TimeType::FULL"
56        );
57
58	foreach( $text_arr as $text_entry){
59                $res_str .= "\n-------------------------------\n";
60                $res_str .= "\nInput text is : $text_entry";
61		$cnt =0;
62
63
64                    foreach( $fmt_array as $fmt_entry ){
65			$res_str .= "\n------------";
66			$res_str .= "\nIntlDateFormatter : ".$fmt_desc_array[$cnt];
67		$parse_pos = 0;
68			$cnt++;
69			$parsed_arr = ut_datefmt_localtime( $fmt_entry , $text_entry , $parse_pos );
70
71				if( $parsed_arr){
72				    $res_str .= "\n";
73				    foreach( $parsed_arr as $key => $value){
74					    $res_str .= "$key : '$value' , ";
75				    }
76				}
77/*
78				else{
79				    //$res_str .= "No values found from LocaleTime parsing.";
80				    $res_str .= "\tError : '".intl_get_error_message()."'";
81				}
82*/
83		    }//end of for $fmt_array
84        }
85
86
87	return $res_str;
88
89}
90
91include_once( 'ut_common.inc' );
92
93// Run the test
94ut_run();
95?>
96--EXPECTF--
97-------------------------------
98
99Input text is : Thursday, December 18, 1969 8:49:59 AM PST
100------------
101IntlDateFormatter : DateType::LONG, TimeType::LONG
102------------
103IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
104------------
105IntlDateFormatter : DateType::FULL, TimeType::FULL
106tm_sec : '59' , tm_min : '49' , tm_hour : '8' , tm_year : '69' , tm_mday : '18' , tm_wday : '4' , tm_yday : '352' , tm_mon : '11' , tm_isdst : '0' ,
107-------------------------------
108
109Input text is : June 18, 1969 8:49:59 AM
110------------
111IntlDateFormatter : DateType::LONG, TimeType::LONG
112------------
113IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
114tm_sec : '59' , tm_min : '49' , tm_hour : '8' , tm_year : '69' , tm_mday : '18' , tm_wday : '3' , tm_yday : '169' , tm_mon : '5' , tm_isdst : '%d' ,
115------------
116IntlDateFormatter : DateType::FULL, TimeType::FULL
117-------------------------------
118
119Input text is : 12/18/69 8:49 AM
120------------
121IntlDateFormatter : DateType::LONG, TimeType::LONG
122------------
123IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
124------------
125IntlDateFormatter : DateType::FULL, TimeType::FULL
126-------------------------------
127
128Input text is : 19691218 08:49 AM
129------------
130IntlDateFormatter : DateType::LONG, TimeType::LONG
131------------
132IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
133------------
134IntlDateFormatter : DateType::FULL, TimeType::FULL
135