Annotation of embedaddon/php/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
1.1.1.2 ! misho 2: datefmt_parse_timestamp_code() with parse pos 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: --INI--
7: datetime.timezone="America/Los_Angeles"
8: --ENV--
9: TZ=America/Los_Angeles
10: --FILE--
11: <?php
12:
13: /*
14: * Test for the datefmt_parse_timestamp function with parse_pos
15: */
16:
17:
18: function ut_main()
19: {
20: $locale_arr = array (
21: 'en_US_CA'
22: );
23:
24: $datetype_arr = array (
25: IntlDateFormatter::FULL,
26: IntlDateFormatter::LONG,
27: IntlDateFormatter::MEDIUM,
28: IntlDateFormatter::SHORT,
29: IntlDateFormatter::NONE
30: );
31:
32: $res_str = '';
33:
34:
35: $text_arr = array (
36: "Sunday, September 18, 3039 4:06:40 PM PT",
37: "Thursday, December 18, 1969 8:49:59 AM PST",
38: //"December 18, 1969 8:49:59 AM PST",
39: "12/18/69 8:49 AM",
40: "20111218 08:49 AM",
41: "19691218 08:49 AM"
42: );
43:
44: foreach( $text_arr as $text_entry){
45: $res_str .= "\n------------\n";
46: $res_str .= "\nInput text is : $text_entry";
47: $res_str .= "\n------------";
48:
49: foreach( $locale_arr as $locale_entry ){
50: $res_str .= "\nLocale is : $locale_entry";
51: $res_str .= "\n------------";
52: foreach( $datetype_arr as $datetype_entry )
53: {
54: $res_str .= "\ndatetype = $datetype_entry ,timetype =$datetype_entry";
55: $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry);
56: $pos = 0;
57: $parsed = ut_datefmt_parse( $fmt , $text_entry, $pos);
58: if( intl_get_error_code() == U_ZERO_ERROR){
59: $res_str .= "\nParsed text is : $parsed; Position = $pos";
60: }else{
61: $res_str .= "\nError while parsing as: '".intl_get_error_message()."'; Position = $pos";
62: }
63: }
64: }
65: }
66: $res_str .= "\n";
67:
68: return $res_str;
69:
70: }
71:
72: include_once( 'ut_common.inc' );
73:
74: // Run the test
75: ut_run();
76: ?>
77: --EXPECT--
78: ------------
79:
80: Input text is : Sunday, September 18, 3039 4:06:40 PM PT
81: ------------
82: Locale is : en_US_CA
83: ------------
84: datetype = 0 ,timetype =0
85: Parsed text is : 33756908800; Position = 40
86: datetype = 1 ,timetype =1
87: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
88: datetype = 2 ,timetype =2
89: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
90: datetype = 3 ,timetype =3
91: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
92: datetype = -1 ,timetype =-1
93: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
94: ------------
95:
96: Input text is : Thursday, December 18, 1969 8:49:59 AM PST
97: ------------
98: Locale is : en_US_CA
99: ------------
100: datetype = 0 ,timetype =0
101: Parsed text is : -1149001; Position = 42
102: datetype = 1 ,timetype =1
103: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
104: datetype = 2 ,timetype =2
105: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
106: datetype = 3 ,timetype =3
107: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
108: datetype = -1 ,timetype =-1
109: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
110: ------------
111:
112: Input text is : 12/18/69 8:49 AM
113: ------------
114: Locale is : en_US_CA
115: ------------
116: datetype = 0 ,timetype =0
117: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
118: datetype = 1 ,timetype =1
119: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
120: datetype = 2 ,timetype =2
121: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
122: datetype = 3 ,timetype =3
123: Parsed text is : -1149060; Position = 16
124: datetype = -1 ,timetype =-1
125: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
126: ------------
127:
128: Input text is : 20111218 08:49 AM
129: ------------
130: Locale is : en_US_CA
131: ------------
132: datetype = 0 ,timetype =0
133: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
134: datetype = 1 ,timetype =1
135: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
136: datetype = 2 ,timetype =2
137: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
138: datetype = 3 ,timetype =3
139: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 8
140: datetype = -1 ,timetype =-1
141: Parsed text is : 1324226940; Position = 17
142: ------------
143:
144: Input text is : 19691218 08:49 AM
145: ------------
146: Locale is : en_US_CA
147: ------------
148: datetype = 0 ,timetype =0
149: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
150: datetype = 1 ,timetype =1
151: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
152: datetype = 2 ,timetype =2
153: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 0
154: datetype = 3 ,timetype =3
155: Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'; Position = 8
156: datetype = -1 ,timetype =-1
157: Parsed text is : -1149060; Position = 17
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>