bug50392.phpt 862 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Bug #50392 (date_create_from_format enforces 6 digits for 'u' format character)
  3. --FILE--
  4. <?php
  5. date_default_timezone_set('Europe/Bratislava');
  6. $base = '2009-03-01 18:00:00';
  7. for ($i = 0; $i < 8; $i++) {
  8. $string = $base . '.' . str_repeat($i, $i);
  9. echo $string, "\n- ";
  10. $result = date_parse_from_format('Y-m-d H:i:s.u', $string);
  11. echo $result['fraction'] ? $result['fraction'] : 'X', "\n";
  12. foreach( $result['errors'] as $error ) {
  13. echo "- ", $error, "\n";
  14. }
  15. echo "\n";
  16. }
  17. ?>
  18. --EXPECT--
  19. 2009-03-01 18:00:00.
  20. - X
  21. - Not enough data available to satisfy format
  22. 2009-03-01 18:00:00.1
  23. - 0.1
  24. 2009-03-01 18:00:00.22
  25. - 0.22
  26. 2009-03-01 18:00:00.333
  27. - 0.333
  28. 2009-03-01 18:00:00.4444
  29. - 0.4444
  30. 2009-03-01 18:00:00.55555
  31. - 0.55555
  32. 2009-03-01 18:00:00.666666
  33. - 0.666666
  34. 2009-03-01 18:00:00.7777777
  35. - 0.777777
  36. - Trailing data