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

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

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