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