Annotation of embedaddon/php/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: datefmt_parse_localtime() with parse pos
                      3: --SKIPIF--
                      4: <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
                      5: --FILE--
                      6: <?php
                      7: 
                      8: /*
                      9:  * Test for the datefmt_parse_localtime  function with parse pos
                     10:  */
                     11: 
                     12: 
                     13: function ut_main()
                     14: {
                     15:        $locale_arr = array (
                     16:                'en_US_CA'
                     17:        );
                     18:        
                     19:        $datetype_arr = array (
                     20:                 IntlDateFormatter::FULL,
                     21:                 IntlDateFormatter::LONG,
                     22:                 IntlDateFormatter::MEDIUM,
                     23:         );
                     24: 
                     25:         $res_str = '';
                     26: 
                     27: 
                     28:        $text_arr = array (
                     29:                "Thursday, December 18, 1969 8:49:59 AM PST",
                     30:                "June 18, 1969 8:49:59 AM ",
                     31:                "12/18/69 8:49 AM",
                     32:                "19691218 08:49 AM"
                     33:        );
                     34: 
                     35:        $fmt1 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::LONG, IntlDateFormatter::LONG);
                     36:        $fmt2 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM);
                     37:        $fmt3 = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::FULL, IntlDateFormatter::FULL);
                     38:        $fmt_array  = array(
                     39:                $fmt1 , $fmt2 ,$fmt3 
                     40:        );
                     41:        $fmt_desc_array  = array(
                     42:                "DateType::LONG, TimeType::LONG",
                     43:                "DateType::MEDIUM, TimeType::MEDIUM",
                     44:                "DateType::FULL, TimeType::FULL"
                     45:        );
                     46: 
                     47:        foreach( $text_arr as $text_entry){
                     48:                 $res_str .= "\n-------------------------------\n";
                     49:                 $res_str .= "\nInput text is : $text_entry";
                     50:                $cnt =0;
                     51:                 foreach( $fmt_array as $fmt_entry ){
                     52:                        $res_str .= "\n------------";
                     53:                        $res_str .= "\nIntlDateFormatter : ".$fmt_desc_array[$cnt];
                     54:                        $cnt++;         
                     55:                        $parsed_arr = ut_datefmt_localtime( $fmt_entry , $text_entry);
                     56: 
                     57:                                if( $parsed_arr){
                     58:                                    $res_str .= "\n";
                     59:                                    foreach( $parsed_arr as $key => $value){
                     60:                                            $res_str .= "$key : '$value' , ";
                     61:                                    }
                     62:                                }
                     63:                                else{
                     64:                                    //$res_str .= "No values found from LocaleTime parsing.";
                     65:                                    $res_str .= "\tError : '".intl_get_error_message()."'";
                     66:                                }
                     67: 
                     68:                }
                     69:         }
                     70: 
                     71: 
                     72:        return $res_str;
                     73: 
                     74: }
                     75: 
                     76: include_once( 'ut_common.inc' );
                     77: 
                     78: // Run the test
                     79: ut_run();
                     80: ?>
                     81: --EXPECT--
                     82: -------------------------------
                     83: 
                     84: Input text is : Thursday, December 18, 1969 8:49:59 AM PST
                     85: ------------
                     86: IntlDateFormatter : DateType::LONG, TimeType::LONG     Error : 'Date parsing failed: U_PARSE_ERROR'
                     87: ------------
                     88: IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM Error : 'Date parsing failed: U_PARSE_ERROR'
                     89: ------------
                     90: IntlDateFormatter : DateType::FULL, TimeType::FULL
                     91: 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' , 
                     92: -------------------------------
                     93: 
                     94: Input text is : June 18, 1969 8:49:59 AM 
                     95: ------------
                     96: IntlDateFormatter : DateType::LONG, TimeType::LONG     Error : 'Date parsing failed: U_PARSE_ERROR'
                     97: ------------
                     98: IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM
                     99: 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 : '1' , 
                    100: ------------
                    101: IntlDateFormatter : DateType::FULL, TimeType::FULL     Error : 'Date parsing failed: U_PARSE_ERROR'
                    102: -------------------------------
                    103: 
                    104: Input text is : 12/18/69 8:49 AM
                    105: ------------
                    106: IntlDateFormatter : DateType::LONG, TimeType::LONG     Error : 'Date parsing failed: U_PARSE_ERROR'
                    107: ------------
                    108: IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM Error : 'Date parsing failed: U_PARSE_ERROR'
                    109: ------------
                    110: IntlDateFormatter : DateType::FULL, TimeType::FULL     Error : 'Date parsing failed: U_PARSE_ERROR'
                    111: -------------------------------
                    112: 
                    113: Input text is : 19691218 08:49 AM
                    114: ------------
                    115: IntlDateFormatter : DateType::LONG, TimeType::LONG     Error : 'Date parsing failed: U_PARSE_ERROR'
                    116: ------------
                    117: IntlDateFormatter : DateType::MEDIUM, TimeType::MEDIUM Error : 'Date parsing failed: U_PARSE_ERROR'
                    118: ------------
                    119: IntlDateFormatter : DateType::FULL, TimeType::FULL     Error : 'Date parsing failed: U_PARSE_ERROR'

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>