1--TEST-- 2Test date_sunset() function : usage variation - Checking sunrise for consecutive days in specific timezone 3--FILE-- 4<?php 5/* Prototype : mixed date_sunset(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]]) 6 * Description: Returns time of sunrise for a given day and location 7 * Source code: ext/date/php_date.c 8 * Alias to functions: 9 */ 10 11echo "*** Testing date_sunset() : usage variation ***\n"; 12 13//Timezones with required data for date_sunrise 14$inputs = array ( 15 //Timezone with Latitude, Longitude and GMT offset 16 "Pacific/Samoa" => array ("Latitude" => -14.24, "Longitude" => -170.72, "GMT" => -11), 17 "US/Alaska" => array ("Latitude" => 61, "Longitude" => -150 , "GMT" => -9), 18 "America/Chicago" => array ("Latitude" => 41.85, "Longitude" => -87.65 , "GMT" => -5), 19 "America/Montevideo" => array ("Latitude" => -34.88, "Longitude" => -56.18 , "GMT" => -3), 20 "Africa/Casablanca" => array ("Latitude" => 33.65, "Longitude" => "-7.58", "GMT" => 0), 21 "Europe/Moscow" => array ("Latitude" => 55.75, "Longitude" => 37.58, "GMT" => 4), 22 "Asia/Hong_Kong" => array ("Latitude" => 22.28, "Longitude" => 114.15 , "GMT" => 8), 23 "Australia/Brisbane" => array ("Latitude" => -27.46, "Longitude" => 153.2 , "GMT" => 10), 24 "Pacific/Wallis" => array ("Latitude" => -13.3, "Longitude" => -176.16, "GMT" => 12), 25); 26 27foreach($inputs as $timezone => $value) { 28 echo "\n--$timezone--\n"; 29 date_default_timezone_set($timezone); 30 $time = mktime(8, 8, 8, 8, 11, 2008); 31 var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $value["Latitude"], $value["Longitude"], 90, $value["GMT"] )); 32 $time = mktime(8, 8, 8, 8, 12, 2008); 33 var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $value["Latitude"], $value["Longitude"], 90, $value["GMT"]) ); 34} 35?> 36===DONE=== 37--EXPECTF-- 38*** Testing date_sunset() : usage variation *** 39 40--Pacific/Samoa-- 41string(5) "18:13" 42string(5) "18:13" 43 44--US/Alaska-- 45string(5) "21:00" 46string(5) "20:57" 47 48--America/Chicago-- 49string(5) "19:51" 50string(5) "19:50" 51 52--America/Montevideo-- 53string(5) "18:08" 54string(5) "18:09" 55 56--Africa/Casablanca-- 57string(5) "19:17" 58string(5) "19:16" 59 60--Europe/Moscow-- 61string(5) "21:09" 62string(5) "21:07" 63 64--Asia/Hong_Kong-- 65string(5) "18:55" 66string(5) "18:54" 67 68--Australia/Brisbane-- 69string(5) "17:21" 70string(5) "17:21" 71 72--Pacific/Wallis-- 73string(5) "17:36" 74string(5) "17:36" 75===DONE=== 76