1--TEST-- 2datefmt_set_timezone_id_code() icu >= 4.8 3--INI-- 4date.timezone=Atlantic/Azores 5--SKIPIF-- 6<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> 7<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?> 8--FILE-- 9<?php 10 11ini_set("intl.error_level", E_WARNING); 12 13/* 14 * Test for the datefmt_set_timezone_id function 15 */ 16 17 18function ut_main() 19{ 20 $timezone_id_arr = array ( 21 'America/New_York', 22 'America/Los_Angeles', 23 'America/Chicago', 24 'CN' 25 ); 26 $timestamp_entry = 0; 27 28 $res_str = ''; 29 30 $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'US/Pacific' , IntlDateFormatter::GREGORIAN ); 31 $timezone_id = ut_datefmt_get_timezone_id( $fmt ); 32 $res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n"; 33 34 foreach( $timezone_id_arr as $timezone_id_entry ) 35 { 36 37 $res_str .= "-----------"; 38 $res_str .= "\nTrying to set timezone_id= $timezone_id_entry"; 39 ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ); 40 $timezone_id = ut_datefmt_get_timezone_id( $fmt ); 41 $res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id"; 42 $formatted = ut_datefmt_format( $fmt, 0); 43 $res_str .= "\nFormatting timestamp=0 resulted in $formatted"; 44 $formatted = ut_datefmt_format( $fmt, 3600); 45 $res_str .= "\nFormatting timestamp=3600 resulted in $formatted"; 46 $res_str .= "\n"; 47 48 } 49 50 return $res_str; 51 52} 53 54include_once( 'ut_common.inc' ); 55 56// Run the test 57ut_run(); 58?> 59--EXPECTF-- 60Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: No such time zone: 'CN' in %sut_common.inc on line %d 61 62Warning: datefmt_set_timezone(): datefmt_set_timezone: No such time zone: 'CN' in %sut_common.inc on line %d 63 64After creation of the dateformatter : timezone_id= US/Pacific 65----------- 66Trying to set timezone_id= America/New_York 67After call to set_timezone_id : timezone_id= America/New_York 68Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Eastern Standard Time 69Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 8:00:00 PM Eastern Standard Time 70----------- 71Trying to set timezone_id= America/Los_Angeles 72After call to set_timezone_id : timezone_id= America/Los_Angeles 73Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 4:00:00 PM Pacific Standard Time 74Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 5:00:00 PM Pacific Standard Time 75----------- 76Trying to set timezone_id= America/Chicago 77After call to set_timezone_id : timezone_id= America/Chicago 78Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 6:00:00 PM Central Standard Time 79Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Central Standard Time 80----------- 81Trying to set timezone_id= CN 82After call to set_timezone_id : timezone_id= America/Chicago 83Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 6:00:00 PM Central Standard Time 84Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Central Standard Time 85