timezone_toDateTimeZone_basic.phpt 953 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. --TEST--
  2. IntlTimeZone::toDateTimeZone(): basic test
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('intl'))
  6. die('skip intl extension not enabled');
  7. --FILE--
  8. <?php
  9. ini_set("intl.error_level", E_WARNING);
  10. ini_set("intl.default_locale", "nl");
  11. date_default_timezone_set('Europe/Lisbon');
  12. function do_test(IntlTimeZone $tz, $proc = false) {
  13. var_dump($tz->getID(), $tz->getRawOffset());
  14. if (!$proc)
  15. $dtz = $tz->toDateTimeZone();
  16. else
  17. $dtz = intltz_to_date_time_zone($tz);
  18. var_dump($dtz->getName(), $dtz->getOffset(new DateTime('2012-01-01 00:00:00')));
  19. }
  20. do_test(IntlTimeZone::createTimeZone('CET'));
  21. do_test(IntlTimeZone::createTimeZone('Europe/Amsterdam'));
  22. do_test(IntlTimeZone::createTimeZone('GMT+0405'), true);
  23. --EXPECTF--
  24. string(3) "CET"
  25. int(3600000)
  26. string(%d) "%rEurope\/Berlin|CET%r"
  27. int(3600)
  28. string(16) "Europe/Amsterdam"
  29. int(3600000)
  30. string(16) "Europe/Amsterdam"
  31. int(3600)
  32. string(%s) "GMT+04%s5"
  33. int(14700000)
  34. string(6) "+04:05"
  35. int(14700)