xref: /PHP-5.6/ext/date/tests/bug50392.phpt (revision 109cc0bf)
1--TEST--
2Bug #50392 (date_create_from_format enforces 6 digits for 'u' format character)
3--FILE--
4<?php
5date_default_timezone_set('Europe/Bratislava');
6
7$base = '2009-03-01 18:00:00';
8
9for ($i = 0; $i < 8; $i++) {
10	$string = $base . '.' . str_repeat($i, $i);
11	echo $string, "\n- ";
12	$result = date_parse_from_format('Y-m-d H:i:s.u', $string);
13	echo $result['fraction'] ? $result['fraction'] : 'X', "\n";
14	foreach( $result['errors'] as $error ) {
15		echo "- ", $error, "\n";
16	}
17	echo "\n";
18}
19?>
20--EXPECT--
212009-03-01 18:00:00.
22- X
23- Data missing
24
252009-03-01 18:00:00.1
26- 0.1
27
282009-03-01 18:00:00.22
29- 0.22
30
312009-03-01 18:00:00.333
32- 0.333
33
342009-03-01 18:00:00.4444
35- 0.4444
36
372009-03-01 18:00:00.55555
38- 0.55555
39
402009-03-01 18:00:00.666666
41- 0.666666
42
432009-03-01 18:00:00.7777777
44- 0.777777
45- Trailing data
46