1--TEST-- 2datefmt_parse_localtime() with parse pos 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_parse_localtime function with parse pos 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 ); 25 26 $res_str = ''; 27 28 29 $text_arr = array ( 30 "Thursday, December 18, 1969 8:49:59 AM PST", 31 "June 18, 1969 8:49:59 AM ", 32 "12/18/69 8:49 AM", 33 "19691218 08:49 AM" 34 ); 35 36 $fmt1 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::LONG, IntlDateFormatter::LONG); 37 $fmt2 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM); 38 $fmt3 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::FULL, IntlDateFormatter::FULL); 39 $fmt_array = array( 40 $fmt1 , $fmt2 ,$fmt3 41 ); 42 $fmt_desc_array = array( 43 "DateType::LONG, TimeType::LONG", 44 "DateType::MEDIUM, TimeType::MEDIUM", 45 "DateType::FULL, TimeType::FULL" 46 ); 47 48 foreach( $text_arr as $text_entry){ 49 $res_str .= "\n-------------------------------\n"; 50 $res_str .= "\nInput text is : $text_entry"; 51 $cnt =0; 52 foreach( $fmt_array as $fmt_entry ){ 53 $res_str .= "\n------------"; 54 $res_str .= "\nIntlDateFormatter : ".$fmt_desc_array[$cnt]; 55 $cnt++; 56 $parsed_arr = ut_datefmt_localtime( $fmt_entry , $text_entry); 57 58 if( $parsed_arr){ 59 $res_str .= "\n"; 60 foreach( $parsed_arr as $key => $value){ 61 $res_str .= "$key : '$value' , "; 62 } 63 } 64 else{ 65 //$res_str .= "No values found from LocaleTime parsing."; 66 $res_str .= "\tError : '".intl_get_error_message()."'"; 67 } 68 69 } 70 } 71 72 73 return $res_str; 74 75} 76 77include_once( 'ut_common.inc' ); 78 79// Run the test 80ut_run(); 81?> 82--EXPECTF-- 83------------------------------- 84 85Input text is : Thursday, December 18, 1969 8:49:59 AM PST 86------------ 87IntlDateFormatter : DateType::LONG, TimeType::LONG Error : 'Date parsing failed: U_PARSE_ERROR' 88------------ 89IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM Error : 'Date parsing failed: U_PARSE_ERROR' 90------------ 91IntlDateFormatter : DateType::FULL, TimeType::FULL 92tm_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' , 93------------------------------- 94 95Input text is : June 18, 1969 8:49:59 AM 96------------ 97IntlDateFormatter : DateType::LONG, TimeType::LONG Error : 'Date parsing failed: U_PARSE_ERROR' 98------------ 99IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM 100tm_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' , 101------------ 102IntlDateFormatter : DateType::FULL, TimeType::FULL Error : 'Date parsing failed: U_PARSE_ERROR' 103------------------------------- 104 105Input text is : 12/18/69 8:49 AM 106------------ 107IntlDateFormatter : DateType::LONG, TimeType::LONG Error : 'Date parsing failed: U_PARSE_ERROR' 108------------ 109IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM Error : 'Date parsing failed: U_PARSE_ERROR' 110------------ 111IntlDateFormatter : DateType::FULL, TimeType::FULL Error : 'Date parsing failed: U_PARSE_ERROR' 112------------------------------- 113 114Input text is : 19691218 08:49 AM 115------------ 116IntlDateFormatter : DateType::LONG, TimeType::LONG Error : 'Date parsing failed: U_PARSE_ERROR' 117------------ 118IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM Error : 'Date parsing failed: U_PARSE_ERROR' 119------------ 120IntlDateFormatter : DateType::FULL, TimeType::FULL Error : 'Date parsing failed: U_PARSE_ERROR' 121