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