DateTimeZone_getLocation.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. --TEST--
  2. DateTimeZone::getLocation -- timezone_location_get — Returns location information for a timezone
  3. public array DateTimeZone::getLocation ( void ) ;
  4. --CREDITS--
  5. marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
  6. --SKIPIF--
  7. <?php
  8. if (phpversion() < "5.3.0") {
  9. die('SKIP php version so lower.');
  10. }
  11. ?>
  12. --FILE--
  13. <?php
  14. $arrayDate = DateTimeZone::listAbbreviations();
  15. $countryCode = array("??");
  16. $countryCodeTest = array("AU", "CA", "ET", "AF", "US", "KZ", "AM");
  17. foreach($arrayDate as $value){
  18. if(NULL != $value[0]['timezone_id']){
  19. $timeZone = new DateTimeZone($value[0]['timezone_id']);
  20. $timeZoneArray = $timeZone->getLocation();
  21. if((!in_array($timeZoneArray['country_code'], $countryCode)) && (NULL != $timeZoneArray['country_code']) && ("" != $timeZoneArray['country_code'])) {
  22. array_push($countryCode, $timeZoneArray['country_code']);
  23. if(in_array($timeZoneArray['country_code'], $countryCodeTest)){
  24. print_r($timeZoneArray);
  25. }
  26. }
  27. }
  28. }
  29. ?>
  30. --CLEAN--
  31. <?php
  32. unset($arrayDate);
  33. unset($countryCode);
  34. unset($countryCodeTest);
  35. ?>
  36. --EXPECTF--
  37. Array
  38. (
  39. [country_code] => %s
  40. [latitude] => %f
  41. [longitude] => %f
  42. [comments] => %s
  43. )
  44. Array
  45. (
  46. [country_code] => %s
  47. [latitude] => %f
  48. [longitude] => %f
  49. [comments] => %s
  50. )
  51. Array
  52. (
  53. [country_code] => %s
  54. [latitude] => %f
  55. [longitude] => %f
  56. [comments] =>
  57. )
  58. Array
  59. (
  60. [country_code] => %s
  61. [latitude] => %f
  62. [longitude] => %f
  63. [comments] => %s
  64. )
  65. Array
  66. (
  67. [country_code] => %s
  68. [latitude] => %f
  69. [longitude] => %f
  70. [comments] => %s
  71. )
  72. Array
  73. (
  74. [country_code] => %s
  75. [latitude] => %f
  76. [longitude] => %f
  77. [comments] =>
  78. )