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

1.1       misho       1: --TEST--
                      2: datefmt_get_pattern_code and datefmt_set_pattern_code()
                      3: --SKIPIF--
                      4: <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
                      5: --FILE--
                      6: 
                      7: <?php
                      8: 
                      9: /*
                     10:  * Test for the datefmt_get_pattern & datefmt_set_pattern function
                     11:  */
                     12: 
                     13: 
                     14: function ut_main()
                     15: {
                     16:         $pattern_arr = array (
                     17:                 'DD-MM-YYYY hh:mm:ss',
                     18:                'yyyy-DDD.hh:mm:ss z',
                     19:                 "yyyy/MM/dd",
                     20:                 "yyyyMMdd"
                     21:         );
                     22: 
                     23:         $res_str = '';
                     24: 
                     25:         $start_pattern = 'dd-MM-YY';
                     26:         $res_str .= "\nCreating IntlDateFormatter with pattern = $start_pattern ";
                     27:         //$fmt = ut_datefmt_create( "en-US",  IntlDateFormatter::SHORT, IntlDateFormatter::SHORT , 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
                     28:         $fmt = ut_datefmt_create( "en-US",  IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
                     29:         $pattern = ut_datefmt_get_pattern( $fmt);
                     30:         $res_str .= "\nAfter call to get_pattern :  pattern= $pattern";
                     31:        $formatted = ut_datefmt_format($fmt,0);
                     32:        $res_str .= "\nResult of formatting timestamp=0 is :  \n$formatted";
                     33: 
                     34: 
                     35:         foreach( $pattern_arr as $pattern_entry )
                     36:         {
                     37:                 $res_str .= "\n-------------------";
                     38:                 $res_str .= "\nSetting IntlDateFormatter with pattern = $pattern_entry ";
                     39:                 ut_datefmt_set_pattern( $fmt , $pattern_entry );
                     40:                 $pattern = ut_datefmt_get_pattern( $fmt);
                     41:                 $res_str .= "\nAfter call to get_pattern :  pattern= $pattern";
                     42:                $formatted = ut_datefmt_format($fmt,0);
                     43:                 $res_str .= "\nResult of formatting timestamp=0 with the new pattern is :  \n$formatted";
                     44:                 $res_str .= "\n";
                     45: 
                     46:         }
                     47: 
                     48:         return $res_str;
                     49: 
                     50: }
                     51: 
                     52: include_once( 'ut_common.inc' );
                     53: 
                     54: // Run the test
                     55: ut_run();
                     56: ?>
                     57: --EXPECT--
                     58: Creating IntlDateFormatter with pattern = dd-MM-YY 
                     59: After call to get_pattern :  pattern= dd-MM-YY
                     60: Result of formatting timestamp=0 is :  
                     61: 31-12-69
                     62: -------------------
                     63: Setting IntlDateFormatter with pattern = DD-MM-YYYY hh:mm:ss 
                     64: After call to get_pattern :  pattern= DD-MM-YYYY hh:mm:ss
                     65: Result of formatting timestamp=0 with the new pattern is :  
                     66: 365-12-1969 07:00:00
                     67: 
                     68: -------------------
                     69: Setting IntlDateFormatter with pattern = yyyy-DDD.hh:mm:ss z 
                     70: After call to get_pattern :  pattern= yyyy-DDD.hh:mm:ss z
                     71: Result of formatting timestamp=0 with the new pattern is :  
                     72: 1969-365.07:00:00 EST
                     73: 
                     74: -------------------
                     75: Setting IntlDateFormatter with pattern = yyyy/MM/dd 
                     76: After call to get_pattern :  pattern= yyyy/MM/dd
                     77: Result of formatting timestamp=0 with the new pattern is :  
                     78: 1969/12/31
                     79: 
                     80: -------------------
                     81: Setting IntlDateFormatter with pattern = yyyyMMdd 
                     82: After call to get_pattern :  pattern= yyyyMMdd
                     83: Result of formatting timestamp=0 with the new pattern is :  
                     84: 19691231

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