File: dateformat_parse_timestamp_parsepos.phpt

package info (click to toggle)
php5 5.3.3-7%2Bsqueeze17
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 122,824 kB
  • ctags: 55,742
  • sloc: ansic: 633,963; php: 19,620; sh: 11,344; xml: 5,816; cpp: 2,400; yacc: 1,745; exp: 1,514; makefile: 1,019; pascal: 623; awk: 537; sql: 22
file content (137 lines) | stat: -rwxr-xr-x 4,223 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
--TEST--
datefmt_parse_timestamp_code()  with parse pos
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
<?php

/*
 * Test for the datefmt_parse_timestamp  function with parse_pos
 */


function ut_main()
{
	$locale_arr = array (
		'en_US_CA'
	);
	
	$datetype_arr = array (
                IntlDateFormatter::FULL,
                IntlDateFormatter::LONG,
                IntlDateFormatter::MEDIUM,
                IntlDateFormatter::SHORT,
                IntlDateFormatter::NONE
        );

        $res_str = '';


	$text_arr = array (
		"Sunday, September 18, 3039 4:06:40 PM PT",
		"Thursday, December 18, 1969 8:49:59 AM PST",
		//"December 18, 1969 8:49:59 AM PST",
		//"12/18/69 8:49 AM",
		"19001218 08:49 AM",
		"19691218 08:49 AM"
	);

	foreach( $text_arr as $text_entry){
                $res_str .= "\n------------\n";
                $res_str .= "\nInput text is : $text_entry";
                $res_str .= "\n------------";

                foreach( $locale_arr as $locale_entry ){
			$res_str .= "\nLocale is : $locale_entry";
			$res_str .= "\n------------";
                        foreach( $datetype_arr as $datetype_entry )
			{
				$res_str .= "\ndatetype = $datetype_entry ,timetype =$datetype_entry ";
				$fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry);
				$parsed = ut_datefmt_parse( $fmt , $text_entry);
				if( intl_get_error_code() == U_ZERO_ERROR){
					$res_str .= "\nParsed text is : $parsed";
				}else{
					$res_str .= "\nError while parsing as: '".intl_get_error_message()."'";
				}
			}
		}
        }


	return $res_str;

}

include_once( 'ut_common.inc' );

// Run the test
ut_run();
?>
--EXPECT--
------------

Input text is : Sunday, September 18, 3039 4:06:40 PM PT
------------
Locale is : en_US_CA
------------
datetype = 0 ,timetype =0 
Error while parsing as: 'datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.: U_BUFFER_OVERFLOW_ERROR'
datetype = 1 ,timetype =1 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = 2 ,timetype =2 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = 3 ,timetype =3 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = -1 ,timetype =-1 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
------------

Input text is : Thursday, December 18, 1969 8:49:59 AM PST
------------
Locale is : en_US_CA
------------
datetype = 0 ,timetype =0 
Parsed text is : -1149001
datetype = 1 ,timetype =1 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = 2 ,timetype =2 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = 3 ,timetype =3 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = -1 ,timetype =-1 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
------------

Input text is : 19001218 08:49 AM
------------
Locale is : en_US_CA
------------
datetype = 0 ,timetype =0 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = 1 ,timetype =1 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = 2 ,timetype =2 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = 3 ,timetype =3 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = -1 ,timetype =-1 
Error while parsing as: 'datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.: U_BUFFER_OVERFLOW_ERROR'
------------

Input text is : 19691218 08:49 AM
------------
Locale is : en_US_CA
------------
datetype = 0 ,timetype =0 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = 1 ,timetype =1 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = 2 ,timetype =2 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = 3 ,timetype =3 
Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
datetype = -1 ,timetype =-1 
Parsed text is : -1149060