Annotation of embedaddon/php/ext/intl/tests/dateformat_localtime.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
1.1.1.2 ! misho 2: datefmt_localtime_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_localtime function
11: */
12:
13:
14: function ut_main()
15: {
16: $locale_arr = array (
17: 'en_US_CA'
18: );
19:
20: $datetype_arr = array (
21: IntlDateFormatter::FULL,
22: IntlDateFormatter::LONG,
23: IntlDateFormatter::MEDIUM,
24: IntlDateFormatter::SHORT,
25: IntlDateFormatter::NONE
26: );
27:
28: $res_str = '';
29:
30: $datetype_arr = array (
31: IntlDateFormatter::FULL,
32: IntlDateFormatter::LONG,
33: IntlDateFormatter::MEDIUM,
34: );
35:
36: $res_str = '';
37:
38:
39: $text_arr = array (
40: "Thursday, December 18, 1969 8:49:59 AM PST",
41: "June 18, 1969 8:49:59 AM ",
42: "12/18/69 8:49 AM",
43: "19691218 08:49 AM"
44: );
45:
46: $fmt1 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::LONG, IntlDateFormatter::LONG);
47: $fmt2 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM);
48: $fmt3 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::FULL, IntlDateFormatter::FULL);
49: $fmt_array = array(
50: $fmt1 , $fmt2 ,$fmt3
51: );
52: $fmt_desc_array = array(
53: "DateType::LONG, TimeType::LONG",
54: "DateType::MEDIUM, TimeType::MEDIUM",
55: "DateType::FULL, TimeType::FULL"
56: );
57:
58: foreach( $text_arr as $text_entry){
59: $res_str .= "\n-------------------------------\n";
60: $res_str .= "\nInput text is : $text_entry";
61: $cnt =0;
62:
63:
64: foreach( $fmt_array as $fmt_entry ){
65: $res_str .= "\n------------";
66: $res_str .= "\nIntlDateFormatter : ".$fmt_desc_array[$cnt];
67: $parse_pos = 0;
68: $cnt++;
69: $parsed_arr = ut_datefmt_localtime( $fmt_entry , $text_entry , $parse_pos );
70:
71: if( $parsed_arr){
72: $res_str .= "\n";
73: foreach( $parsed_arr as $key => $value){
74: $res_str .= "$key : '$value' , ";
75: }
76: }
77: /*
78: else{
79: //$res_str .= "No values found from LocaleTime parsing.";
80: $res_str .= "\tError : '".intl_get_error_message()."'";
81: }
82: */
83: }//end of for $fmt_array
84: }
85:
86:
87: return $res_str;
88:
89: }
90:
91: include_once( 'ut_common.inc' );
92:
93: // Run the test
94: ut_run();
95: ?>
1.1.1.2 ! misho 96: --EXPECTF--
1.1 misho 97: -------------------------------
98:
99: Input text is : Thursday, December 18, 1969 8:49:59 AM PST
100: ------------
101: IntlDateFormatter : DateType::LONG, TimeType::LONG
102: ------------
103: IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
104: ------------
105: IntlDateFormatter : DateType::FULL, TimeType::FULL
106: tm_sec : '59' , tm_min : '49' , tm_hour : '8' , tm_year : '69' , tm_mday : '18' , tm_wday : '4' , tm_yday : '352' , tm_mon : '11' , tm_isdst : '0' ,
107: -------------------------------
108:
109: Input text is : June 18, 1969 8:49:59 AM
110: ------------
111: IntlDateFormatter : DateType::LONG, TimeType::LONG
112: ------------
113: IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
1.1.1.2 ! misho 114: tm_sec : '59' , tm_min : '49' , tm_hour : '8' , tm_year : '69' , tm_mday : '18' , tm_wday : '3' , tm_yday : '169' , tm_mon : '5' , tm_isdst : '%d' ,
1.1 misho 115: ------------
116: IntlDateFormatter : DateType::FULL, TimeType::FULL
117: -------------------------------
118:
119: Input text is : 12/18/69 8:49 AM
120: ------------
121: IntlDateFormatter : DateType::LONG, TimeType::LONG
122: ------------
123: IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
124: ------------
125: IntlDateFormatter : DateType::FULL, TimeType::FULL
126: -------------------------------
127:
128: Input text is : 19691218 08:49 AM
129: ------------
130: IntlDateFormatter : DateType::LONG, TimeType::LONG
131: ------------
132: IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
133: ------------
1.1.1.2 ! misho 134: IntlDateFormatter : DateType::FULL, TimeType::FULL
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>