Annotation of embedaddon/php/ext/intl/tests/dateformat_localtime.phpt, revision 1.1

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

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