1--TEST-- 2datefmt_get_pattern_code and datefmt_set_pattern_code() icu >= 4.8 3--SKIPIF-- 4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> 5<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?> 6--FILE-- 7 8<?php 9 10/* 11 * Test for the datefmt_get_pattern & datefmt_set_pattern function 12 */ 13 14 15function ut_main() 16{ 17 $pattern_arr = array ( 18 'DD-MM-YYYY hh:mm:ss', 19 'yyyy-DDD.hh:mm:ss z', 20 "yyyy/MM/dd", 21 "yyyyMMdd" 22 ); 23 24 $res_str = ''; 25 26 $start_pattern = 'dd-MM-YY'; 27 $res_str .= "\nCreating IntlDateFormatter with pattern = $start_pattern "; 28 //$fmt = ut_datefmt_create( "en-US", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT , 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern ); 29 $fmt = ut_datefmt_create( "en-US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern ); 30 $pattern = ut_datefmt_get_pattern( $fmt); 31 $res_str .= "\nAfter call to get_pattern : pattern= $pattern"; 32 $formatted = ut_datefmt_format($fmt,0); 33 $res_str .= "\nResult of formatting timestamp=0 is : \n$formatted"; 34 35 36 foreach( $pattern_arr as $pattern_entry ) 37 { 38 $res_str .= "\n-------------------"; 39 $res_str .= "\nSetting IntlDateFormatter with pattern = $pattern_entry "; 40 ut_datefmt_set_pattern( $fmt , $pattern_entry ); 41 $pattern = ut_datefmt_get_pattern( $fmt); 42 $res_str .= "\nAfter call to get_pattern : pattern= $pattern"; 43 $formatted = ut_datefmt_format($fmt,0); 44 $res_str .= "\nResult of formatting timestamp=0 with the new pattern is : \n$formatted"; 45 $res_str .= "\n"; 46 47 } 48 49 return $res_str; 50 51} 52 53include_once( 'ut_common.inc' ); 54 55// Run the test 56ut_run(); 57?> 58--EXPECT-- 59Creating IntlDateFormatter with pattern = dd-MM-YY 60After call to get_pattern : pattern= dd-MM-YY 61Result of formatting timestamp=0 is : 6231-12-70 63------------------- 64Setting IntlDateFormatter with pattern = DD-MM-YYYY hh:mm:ss 65After call to get_pattern : pattern= DD-MM-YYYY hh:mm:ss 66Result of formatting timestamp=0 with the new pattern is : 67365-12-1970 07:00:00 68 69------------------- 70Setting IntlDateFormatter with pattern = yyyy-DDD.hh:mm:ss z 71After call to get_pattern : pattern= yyyy-DDD.hh:mm:ss z 72Result of formatting timestamp=0 with the new pattern is : 731969-365.07:00:00 EST 74 75------------------- 76Setting IntlDateFormatter with pattern = yyyy/MM/dd 77After call to get_pattern : pattern= yyyy/MM/dd 78Result of formatting timestamp=0 with the new pattern is : 791969/12/31 80 81------------------- 82Setting IntlDateFormatter with pattern = yyyyMMdd 83After call to get_pattern : pattern= yyyyMMdd 84Result of formatting timestamp=0 with the new pattern is : 8519691231 86