1
0
mirror of https://github.com/php/php-src.git synced 2026-03-30 04:02:19 +02:00
Files
archived-php-src/ext/intl/tests/dateformat_get_set_pattern2.phpt
Peter Kokot d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00

84 lines
2.8 KiB
PHP

--TEST--
datefmt_get_pattern_code and datefmt_set_pattern_code() icu >= 4.8
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip intl extension not loaded'; ?>
--FILE--
<?php
/*
* Test for the datefmt_get_pattern & datefmt_set_pattern function
*/
function ut_main()
{
$pattern_arr = array (
'DD-MM-YYYY hh:mm:ss',
'yyyy-DDD.hh:mm:ss z',
"yyyy/MM/dd",
"yyyyMMdd"
);
$res_str = '';
$start_pattern = 'dd-MM-YY';
$res_str .= "\nCreating IntlDateFormatter with pattern = $start_pattern ";
//$fmt = ut_datefmt_create( "en-US", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT , 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
$fmt = ut_datefmt_create( "en-US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern );
$pattern = ut_datefmt_get_pattern( $fmt);
$res_str .= "\nAfter call to get_pattern : pattern= $pattern";
$formatted = ut_datefmt_format($fmt,0);
$res_str .= "\nResult of formatting timestamp=0 is : \n$formatted";
foreach( $pattern_arr as $pattern_entry )
{
$res_str .= "\n-------------------";
$res_str .= "\nSetting IntlDateFormatter with pattern = $pattern_entry ";
ut_datefmt_set_pattern( $fmt , $pattern_entry );
$pattern = ut_datefmt_get_pattern( $fmt);
$res_str .= "\nAfter call to get_pattern : pattern= $pattern";
$formatted = ut_datefmt_format($fmt,0);
$res_str .= "\nResult of formatting timestamp=0 with the new pattern is : \n$formatted";
$res_str .= "\n";
}
return $res_str;
}
include_once( 'ut_common.inc' );
// Run the test
ut_run();
?>
--EXPECT--
Creating IntlDateFormatter with pattern = dd-MM-YY
After call to get_pattern : pattern= dd-MM-YY
Result of formatting timestamp=0 is :
31-12-70
-------------------
Setting IntlDateFormatter with pattern = DD-MM-YYYY hh:mm:ss
After call to get_pattern : pattern= DD-MM-YYYY hh:mm:ss
Result of formatting timestamp=0 with the new pattern is :
365-12-1970 07:00:00
-------------------
Setting IntlDateFormatter with pattern = yyyy-DDD.hh:mm:ss z
After call to get_pattern : pattern= yyyy-DDD.hh:mm:ss z
Result of formatting timestamp=0 with the new pattern is :
1969-365.07:00:00 EST
-------------------
Setting IntlDateFormatter with pattern = yyyy/MM/dd
After call to get_pattern : pattern= yyyy/MM/dd
Result of formatting timestamp=0 with the new pattern is :
1969/12/31
-------------------
Setting IntlDateFormatter with pattern = yyyyMMdd
After call to get_pattern : pattern= yyyyMMdd
Result of formatting timestamp=0 with the new pattern is :
19691231