dateformat_calendars.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. IntlDateFormatter, calendars and time zone
  3. --INI--
  4. date.timezone=Atlantic/Azores
  5. --EXTENSIONS--
  6. intl
  7. --SKIPIF--
  8. <?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
  9. --FILE--
  10. <?php
  11. ini_set("intl.error_level", E_WARNING);
  12. $fmt1 = new IntlDateFormatter('en_US',
  13. IntlDateFormatter::FULL,
  14. IntlDateFormatter::FULL,
  15. 'GMT+05:12',
  16. IntlDateFormatter::TRADITIONAL);
  17. $fmt2 = new IntlDateFormatter('en_US',
  18. IntlDateFormatter::FULL,
  19. IntlDateFormatter::FULL,
  20. 'GMT+05:12',
  21. IntlDateFormatter::GREGORIAN);
  22. $fmt3 = new IntlDateFormatter('en_US@calendar=hebrew',
  23. IntlDateFormatter::FULL,
  24. IntlDateFormatter::FULL,
  25. 'GMT+05:12',
  26. IntlDateFormatter::TRADITIONAL);
  27. var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000')));
  28. var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000')));
  29. var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000')));
  30. new IntlDateFormatter('en_US@calendar=hebrew',
  31. IntlDateFormatter::FULL,
  32. IntlDateFormatter::FULL,
  33. 'GMT+05:12',
  34. -1);
  35. ?>
  36. ==DONE==
  37. --EXPECTF--
  38. string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12"
  39. string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12"
  40. string(42) "Sunday, Tevet 6, 5772 5:12:00 AM GMT+05:12"
  41. Fatal error: Uncaught IntlException: IntlDateFormatter::__construct(): datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %sdateformat_calendars.php:%d
  42. Stack trace:
  43. #0 %sdateformat_calendars.php(%d): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1)
  44. #1 {main}
  45. thrown in %sdateformat_calendars.php on line %d