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