1--TEST--
2datefmt_get_pattern_code and datefmt_set_pattern_code() icu >= 4.8
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip intl extension not loaded'; ?>
5--FILE--
6<?php
7
8/*
9 * Test for the datefmt_get_pattern & datefmt_set_pattern function
10 */
11
12
13function ut_main()
14{
15        $pattern_arr = array (
16                'DD-MM-YYYY hh:mm:ss',
17		'yyyy-DDD.hh:mm:ss z',
18                "yyyy/MM/dd",
19                "yyyyMMdd"
20        );
21
22        $res_str = '';
23
24        $start_pattern = 'dd-MM-YY';
25        $res_str .= "\nCreating IntlDateFormatter with pattern = $start_pattern ";
26        //$fmt = ut_datefmt_create( "en-US",  IntlDateFormatter::SHORT, IntlDateFormatter::SHORT , 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
27        $fmt = ut_datefmt_create( "en-US",  IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
28        $pattern = ut_datefmt_get_pattern( $fmt);
29        $res_str .= "\nAfter call to get_pattern :  pattern= $pattern";
30	$formatted = ut_datefmt_format($fmt,0);
31	$res_str .= "\nResult of formatting timestamp=0 is :  \n$formatted";
32
33
34        foreach( $pattern_arr as $pattern_entry )
35        {
36                $res_str .= "\n-------------------";
37                $res_str .= "\nSetting IntlDateFormatter with pattern = $pattern_entry ";
38                ut_datefmt_set_pattern( $fmt , $pattern_entry );
39                $pattern = ut_datefmt_get_pattern( $fmt);
40                $res_str .= "\nAfter call to get_pattern :  pattern= $pattern";
41		$formatted = ut_datefmt_format($fmt,0);
42                $res_str .= "\nResult of formatting timestamp=0 with the new pattern is :  \n$formatted";
43                $res_str .= "\n";
44
45        }
46
47        return $res_str;
48
49}
50
51include_once( 'ut_common.inc' );
52
53// Run the test
54ut_run();
55?>
56--EXPECT--
57Creating IntlDateFormatter with pattern = dd-MM-YY
58After call to get_pattern :  pattern= dd-MM-YY
59Result of formatting timestamp=0 is :
6031-12-70
61-------------------
62Setting IntlDateFormatter with pattern = DD-MM-YYYY hh:mm:ss
63After call to get_pattern :  pattern= DD-MM-YYYY hh:mm:ss
64Result of formatting timestamp=0 with the new pattern is :
65365-12-1970 07:00:00
66
67-------------------
68Setting IntlDateFormatter with pattern = yyyy-DDD.hh:mm:ss z
69After call to get_pattern :  pattern= yyyy-DDD.hh:mm:ss z
70Result of formatting timestamp=0 with the new pattern is :
711969-365.07:00:00 EST
72
73-------------------
74Setting IntlDateFormatter with pattern = yyyy/MM/dd
75After call to get_pattern :  pattern= yyyy/MM/dd
76Result of formatting timestamp=0 with the new pattern is :
771969/12/31
78
79-------------------
80Setting IntlDateFormatter with pattern = yyyyMMdd
81After call to get_pattern :  pattern= yyyyMMdd
82Result of formatting timestamp=0 with the new pattern is :
8319691231
84