dateformat_calendars.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. IntlDateFormatter, calendars and time zone
  3. --INI--
  4. date.timezone=Atlantic/Azores
  5. --SKIPIF--
  6. <?php
  7. if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
  8. <?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.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. Warning: 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 %s on line %d
  42. ==DONE==