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<?php
8
9/*
10 * Test for the datefmt_get_pattern & datefmt_set_pattern function
11 */
12
13
14function ut_main()
15{
16        $pattern_arr = array (
17                'DD-MM-YYYY hh:mm:ss',
18		'yyyy-DDD.hh:mm:ss z',
19                "yyyy/MM/dd",
20                "yyyyMMdd"
21        );
22
23        $res_str = '';
24
25        $start_pattern = 'dd-MM-YY';
26        $res_str .= "\nCreating IntlDateFormatter with pattern = $start_pattern ";
27        //$fmt = ut_datefmt_create( "en-US",  IntlDateFormatter::SHORT, IntlDateFormatter::SHORT , 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
28        $fmt = ut_datefmt_create( "en-US",  IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
29        $pattern = ut_datefmt_get_pattern( $fmt);
30        $res_str .= "\nAfter call to get_pattern :  pattern= $pattern";
31	$formatted = ut_datefmt_format($fmt,0);
32	$res_str .= "\nResult of formatting timestamp=0 is :  \n$formatted";
33
34
35        foreach( $pattern_arr as $pattern_entry )
36        {
37                $res_str .= "\n-------------------";
38                $res_str .= "\nSetting IntlDateFormatter with pattern = $pattern_entry ";
39                ut_datefmt_set_pattern( $fmt , $pattern_entry );
40                $pattern = ut_datefmt_get_pattern( $fmt);
41                $res_str .= "\nAfter call to get_pattern :  pattern= $pattern";
42		$formatted = ut_datefmt_format($fmt,0);
43                $res_str .= "\nResult of formatting timestamp=0 with the new pattern is :  \n$formatted";
44                $res_str .= "\n";
45
46        }
47
48        return $res_str;
49
50}
51
52include_once( 'ut_common.inc' );
53
54// Run the test
55ut_run();
56?>
57--EXPECT--
58Creating IntlDateFormatter with pattern = dd-MM-YY
59After call to get_pattern :  pattern= dd-MM-YY
60Result of formatting timestamp=0 is :
6131-12-70
62-------------------
63Setting IntlDateFormatter with pattern = DD-MM-YYYY hh:mm:ss
64After call to get_pattern :  pattern= DD-MM-YYYY hh:mm:ss
65Result of formatting timestamp=0 with the new pattern is :
66365-12-1970 07:00:00
67
68-------------------
69Setting IntlDateFormatter with pattern = yyyy-DDD.hh:mm:ss z
70After call to get_pattern :  pattern= yyyy-DDD.hh:mm:ss z
71Result of formatting timestamp=0 with the new pattern is :
721969-365.07:00:00 EST
73
74-------------------
75Setting IntlDateFormatter with pattern = yyyy/MM/dd
76After call to get_pattern :  pattern= yyyy/MM/dd
77Result of formatting timestamp=0 with the new pattern is :
781969/12/31
79
80-------------------
81Setting IntlDateFormatter with pattern = yyyyMMdd
82After call to get_pattern :  pattern= yyyyMMdd
83Result of formatting timestamp=0 with the new pattern is :
8419691231
85