php-src/ext/date/tests/date-lenient-create.phpt
Adam Harvey fdb2709dd2 Add microseconds to the serialised form of DateTime objects.
Fixes bug #67308 (Serialize of DateTime truncates fractions of second).
2014-05-21 14:55:52 -05:00

150 lines
2.4 KiB
PHP

--TEST--
Test for + character in date format
--FILE--
<?php
$tz = new DateTimeZone("UTC");
$date = "06/08/04 12:00";
echo "==\n";
print_r( date_create_from_format( 'm/d/y', $date , $tz) );
print_r( date_get_last_errors() );
echo "==\n";
print_r( date_create_from_format( 'm/d/y+', $date , $tz)->setTime(0, 0) );
print_r( date_get_last_errors() );
echo "==\n";
print_r( date_create_from_format( '+m/d/y', $date , $tz)->setTime(0, 0) );
print_r( date_get_last_errors() );
echo "==\n";
print_r( date_create_from_format( 'm/d/y++', $date , $tz)->setTime(0, 0) );
print_r( date_get_last_errors() );
echo "==\n";
$date = "06/08/04";
print_r( date_create_from_format( 'm/d/y+', $date , $tz)->setTime(0, 0) );
print_r( date_get_last_errors() );
echo "==\n";
print_r( date_create_from_format( '+m/d/y', $date , $tz)->setTime(0, 0) );
print_r( date_get_last_errors() );
echo "==\n";
?>
--EXPECT--
==
Array
(
[warning_count] => 0
[warnings] => Array
(
)
[error_count] => 1
[errors] => Array
(
[8] => Trailing data
)
)
==
DateTime Object
(
[date] => 2004-06-08 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
Array
(
[warning_count] => 1
[warnings] => Array
(
[8] => Trailing data
)
[error_count] => 0
[errors] => Array
(
)
)
==
DateTime Object
(
[date] => 2004-06-08 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
Array
(
[warning_count] => 1
[warnings] => Array
(
[8] => Trailing data
)
[error_count] => 0
[errors] => Array
(
)
)
==
DateTime Object
(
[date] => 2004-06-08 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
Array
(
[warning_count] => 1
[warnings] => Array
(
[8] => Trailing data
)
[error_count] => 0
[errors] => Array
(
)
)
==
DateTime Object
(
[date] => 2004-06-08 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
Array
(
[warning_count] => 0
[warnings] => Array
(
)
[error_count] => 0
[errors] => Array
(
)
)
==
DateTime Object
(
[date] => 2004-06-08 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
Array
(
[warning_count] => 0
[warnings] => Array
(
)
[error_count] => 0
[errors] => Array
(
)
)
==