Annotation of embedaddon/php/ext/intl/tests/dateformat_set_timezone_id.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
1.1.1.2 ! misho 2: datefmt_set_timezone_id_code() icu <= 4.2
1.1 misho 3: --SKIPIF--
4: <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
1.1.1.2 ! misho 5: <?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
1.1 misho 6: --FILE--
7: <?php
8:
9: /*
10: * Test for the datefmt_set_timezone_id function
11: */
12:
13:
14: function 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:
50: include_once( 'ut_common.inc' );
51:
52: // Run the test
53: ut_run();
54: ?>
55: --EXPECT--
56: After creation of the dateformatter : timezone_id= America/San_Francisco
57: -----------
58: Trying to set timezone_id= America/New_York
59: After call to set_timezone_id : timezone_id= America/New_York
60: Formatting timestamp=0 resulted in Wednesday, December 31, 1969 7:00:00 PM Eastern Standard Time
61: Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 8:00:00 PM Eastern Standard Time
62: -----------
63: Trying to set timezone_id= America/Los_Angeles
64: After call to set_timezone_id : timezone_id= America/Los_Angeles
65: Formatting timestamp=0 resulted in Wednesday, December 31, 1969 4:00:00 PM Pacific Standard Time
66: Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 5:00:00 PM Pacific Standard Time
67: -----------
68: Trying to set timezone_id= America/Chicago
69: After call to set_timezone_id : timezone_id= America/Chicago
70: Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Central Standard Time
71: Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time
72: -----------
73: Trying to set timezone_id= CN
74: After call to set_timezone_id : timezone_id= CN
75: Formatting timestamp=0 resulted in Thursday, January 1, 1970 12:00:00 AM GMT+00:00
1.1.1.2 ! misho 76: Formatting timestamp=3600 resulted in Thursday, January 1, 1970 1:00:00 AM GMT+00:00
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>