1--TEST-- 2datefmt_set_timezone_id_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<?php 8 9/* 10 * Test for the datefmt_set_timezone_id function 11 */ 12 13 14function ut_main() 15{ 16 $timezone_id_arr = array ( 17 'America/New_York', 18 'America/Los_Angeles', 19 'America/Chicago', 20 'CN' 21 ); 22 $timestamp_entry = 0; 23 24 $res_str = ''; 25 26 $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/San_Francisco' , IntlDateFormatter::GREGORIAN ); 27 $timezone_id = ut_datefmt_get_timezone_id( $fmt ); 28 $res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n"; 29 30 foreach( $timezone_id_arr as $timezone_id_entry ) 31 { 32 33 $res_str .= "-----------"; 34 $res_str .= "\nTrying to set timezone_id= $timezone_id_entry"; 35 ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ); 36 $timezone_id = ut_datefmt_get_timezone_id( $fmt ); 37 $res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id"; 38 $formatted = ut_datefmt_format( $fmt, 0); 39 $res_str .= "\nFormatting timestamp=0 resulted in $formatted"; 40 $formatted = ut_datefmt_format( $fmt, 3600); 41 $res_str .= "\nFormatting timestamp=3600 resulted in $formatted"; 42 $res_str .= "\n"; 43 44 } 45 46 return $res_str; 47 48} 49 50include_once( 'ut_common.inc' ); 51 52// Run the test 53ut_run(); 54?> 55--EXPECT-- 56After creation of the dateformatter : timezone_id= America/San_Francisco 57----------- 58Trying to set timezone_id= America/New_York 59After call to set_timezone_id : timezone_id= America/New_York 60Formatting timestamp=0 resulted in Wednesday, December 31, 1969 7:00:00 PM Eastern Standard Time 61Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 8:00:00 PM Eastern Standard Time 62----------- 63Trying to set timezone_id= America/Los_Angeles 64After call to set_timezone_id : timezone_id= America/Los_Angeles 65Formatting timestamp=0 resulted in Wednesday, December 31, 1969 4:00:00 PM Pacific Standard Time 66Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 5:00:00 PM Pacific Standard Time 67----------- 68Trying to set timezone_id= America/Chicago 69After call to set_timezone_id : timezone_id= America/Chicago 70Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Central Standard Time 71Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time 72----------- 73Trying to set timezone_id= CN 74After call to set_timezone_id : timezone_id= CN 75Formatting timestamp=0 resulted in Thursday, January 1, 1970 12:00:00 AM GMT 76Formatting timestamp=3600 resulted in Thursday, January 1, 1970 1:00:00 AM GMT 77