1--TEST-- 2datefmt_parse_timestamp_code() 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--INI-- 7datetime.timezone="America/Los_Angeles" 8--ENV-- 9TZ=America/Los_Angeles 10--FILE-- 11<?php 12 13/* 14 * Test for the datefmt_parse_timestamp function with parse_pos 15 */ 16 17 18function ut_main() 19{ 20 $locale_arr = array ( 21 'en_US_CA' 22 ); 23 24 $datetype_arr = array ( 25 IntlDateFormatter::FULL, 26 IntlDateFormatter::LONG, 27 IntlDateFormatter::MEDIUM, 28 IntlDateFormatter::SHORT, 29 IntlDateFormatter::NONE 30 ); 31 32 $res_str = ''; 33 34 35 $text_arr = array ( 36 "Sunday, September 18, 3039 4:06:40 PM PT", 37 "Thursday, December 18, 1969 8:49:59 AM PST", 38 //"December 18, 1969 8:49:59 AM PST", 39 "12/18/69 8:49 AM", 40 "20111218 08:49 AM", 41 "19691218 08:49 AM" 42 ); 43 44 foreach( $text_arr as $text_entry){ 45 $res_str .= "\n------------\n"; 46 $res_str .= "\nInput text is : $text_entry"; 47 $res_str .= "\n------------"; 48 49 foreach( $locale_arr as $locale_entry ){ 50 $res_str .= "\nLocale is : $locale_entry"; 51 $res_str .= "\n------------"; 52 foreach( $datetype_arr as $datetype_entry ) 53 { 54 $res_str .= "\ndatetype = $datetype_entry ,timetype =$datetype_entry"; 55 $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry); 56 $pos = 0; 57 $parsed = ut_datefmt_parse( $fmt , $text_entry, $pos); 58 if( intl_get_error_code() == U_ZERO_ERROR){ 59 $res_str .= "\nParsed text is : $parsed; Position = $pos"; 60 }else{ 61 $res_str .= "\nError while parsing as: '".intl_get_error_message()."'; Position = $pos"; 62 } 63 } 64 } 65 } 66 $res_str .= "\n"; 67 68 return $res_str; 69 70} 71 72include_once( 'ut_common.inc' ); 73 74// Run the test 75ut_run(); 76?> 77--EXPECT-- 78------------ 79 80Input text is : Sunday, September 18, 3039 4:06:40 PM PT 81------------ 82Locale is : en_US_CA 83------------ 84datetype = 0 ,timetype =0 85Parsed text is : 33756908800; Position = 40 86datetype = 1 ,timetype =1 87Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 88datetype = 2 ,timetype =2 89Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 90datetype = 3 ,timetype =3 91Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 92datetype = -1 ,timetype =-1 93Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 94------------ 95 96Input text is : Thursday, December 18, 1969 8:49:59 AM PST 97------------ 98Locale is : en_US_CA 99------------ 100datetype = 0 ,timetype =0 101Parsed text is : -1149001; Position = 42 102datetype = 1 ,timetype =1 103Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 104datetype = 2 ,timetype =2 105Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 106datetype = 3 ,timetype =3 107Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 108datetype = -1 ,timetype =-1 109Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 110------------ 111 112Input text is : 12/18/69 8:49 AM 113------------ 114Locale is : en_US_CA 115------------ 116datetype = 0 ,timetype =0 117Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 118datetype = 1 ,timetype =1 119Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 120datetype = 2 ,timetype =2 121Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 122datetype = 3 ,timetype =3 123Parsed text is : -1149060; Position = 16 124datetype = -1 ,timetype =-1 125Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 126------------ 127 128Input text is : 20111218 08:49 AM 129------------ 130Locale is : en_US_CA 131------------ 132datetype = 0 ,timetype =0 133Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 134datetype = 1 ,timetype =1 135Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 136datetype = 2 ,timetype =2 137Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 138datetype = 3 ,timetype =3 139Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 8 140datetype = -1 ,timetype =-1 141Parsed text is : 1324226940; Position = 17 142------------ 143 144Input text is : 19691218 08:49 AM 145------------ 146Locale is : en_US_CA 147------------ 148datetype = 0 ,timetype =0 149Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 150datetype = 1 ,timetype =1 151Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 152datetype = 2 ,timetype =2 153Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0 154datetype = 3 ,timetype =3 155Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 8 156datetype = -1 ,timetype =-1 157Parsed text is : -1149060; Position = 17 158