Changeset 527059
- Timestamp:
- 04/04/2012 04:23:29 AM (14 years ago)
- Location:
- sunrise-sunset/trunk
- Files:
-
- 5 edited
-
cities.txt (modified) (1 diff)
-
city.php (modified) (1 diff)
-
functions.php (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
-
sunrisesunset.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sunrise-sunset/trunk/cities.txt
r525899 r527059 1 Arizona:33.29:-122.04 2 Atlanta:33.65:-84.42 3 Charlotte,NC:35.22:-80.93 4 Chicago:41.51:-87.39 5 Crossville,TN:35.95:-85.08 6 Los Angeles:34.30:-118.15 7 Lexington, KY:38.05:-85.00 8 Miami:25.82:-80.28 9 Nashville,TN:36.12:-86.68 10 Orlando,FL:28.55:-81.33 11 Richmond,VA:37.50:-77.33 12 Roanoke Muni,VA:37.32:-79.97 1 city:latitude:longitude:timezone:summertimezone 2 Tucson, AZ:33.29:-122.04:MST:none 3 Atlanta, GA:33.65:-84.42:EST:EDT 4 Charlotte,NC:35.22:-80.93:EST:EDT 5 Chicago, IL:41.51:-87.39:CST:CDT 6 Crossville,TN:35.95:-85.08:CST:CDT 7 Los Angeles, CA:34.30:-118.15:PST:PDT 8 Lexington, KY:38.05:-85.00:EST:EDT 9 Miami, FL:25.82:-80.28:EST:EDT 10 Nashville,TN:36.12:-86.68:CST:CDT 11 Orlando,FL:28.55:-81.33:EST:EDT 12 Richmond,VA:37.50:-77.33:EST:EDT 13 Roanoke Muni,VA:37.32:-79.97:EST:EDT -
sunrise-sunset/trunk/city.php
r525899 r527059 3 3 class City 4 4 { 5 private $_name; 6 private $_latitude; 7 private $_longitude; 8 private $_timezone; 9 private $_summerTimezone; 5 10 6 private $name; 7 private $latitude; 8 private $longitude; 9 10 function __construct($name, $latitude, $longitude) 11 function __construct($name, $latitude, $longitude, $timezone, $summerTimezone) 11 12 { 12 $this->name = $name; 13 $this->latitude = $latitude; 14 $this->longitude = $longitude; 13 $this->_name = $name; 14 $this->_latitude = $latitude; 15 $this->_longitude = $longitude; 16 $this->_timezone = $timezone; 17 $this->_summerTimezone = $summerTimezone; 15 18 } 16 19 17 20 21 public function setSummerTimezone($summerTimezone) 22 { 23 $this->_summerTimezone = $summerTimezone; 24 } 25 26 public function getSummerTimezone() 27 { 28 return $this->_summerTimezone; 29 } 30 31 public function setTimezone($timezone) 32 { 33 $this->_timezone = $timezone; 34 } 35 36 public function getTimezone() 37 { 38 return $this->_timezone; 39 } 40 18 41 public function setLatitude($latitude) 19 42 { 20 $this-> latitude = $latitude;43 $this->_latitude = $latitude; 21 44 } 22 45 23 46 public function getLatitude() 24 47 { 25 return $this-> latitude;48 return $this->_latitude; 26 49 } 27 50 28 51 public function setLongitude($longitude) 29 52 { 30 $this-> longitude = $longitude;53 $this->_longitude = $longitude; 31 54 } 32 55 33 56 public function getLongitude() 34 57 { 35 return $this-> longitude;58 return $this->_longitude; 36 59 } 37 60 38 61 public function setName($name) 39 62 { 40 $this-> name = $name;63 $this->_name = $name; 41 64 } 42 65 43 66 public function getName() 44 67 { 45 return $this-> name;68 return $this->_name; 46 69 } 47 70 } -
sunrise-sunset/trunk/functions.php
r519692 r527059 2 2 3 3 4 5 function populateLatitude()6 {7 // $latitude = array('America/Chicago' => 41.51, 'America/Los_Angeles' => 34.30, 'America/New_York' => 40.47, 'US/Arizona' => 33.29);8 9 $latitude = array();10 11 global $CITIES;12 foreach ($CITIES as $city) {13 $latitude[$city->getTimezone] = $city->getLatitude();14 }15 return $latitude;16 17 }18 -
sunrise-sunset/trunk/readme.txt
r525899 r527059 4 4 Requires at least: 3.0 5 5 Tested up to: 3.3.1 6 Stable tag: 1.0. 86 Stable tag: 1.0.9 7 7 License: GPLv2 8 8 … … 14 14 using a drop down list. 15 15 16 In order to add a city please add a line to the cities.txt file. The file formate is:17 <city name>:<timezone>:<latitude>:<longitude>16 To Add a city go to city.txt and add a line with the following format: 17 <city>:<latitude>:<longitude>:<timezone>:<summertimezone> 18 18 19 19 For example: 20 Orlando,FL:America/New_York:28.55:-81.33 20 Miami, FL:25.82:-80.28:EST:EDT 21 21 22 Logitude is always negative for cities in the United States. This plugin should handle cities from different22 Logitude is always negative for cities in the United States. This plugin should handle cities from different 23 23 countries, but it has not been tested. 24 24 … … 48 48 = How do I add more cities to this list? = 49 49 Add a line in the cities.txt file with the following format: 50 <city name>:<timezone>:<latitude>:<longitude>50 <city>:<latitude>:<longitude>:<timezone>:<summertimezone> 51 51 52 52 For example: 53 Orlando,FL:America/New_York:28.55:-81.33 53 Miami, FL:25.82:-80.28:EST:EDT 54 54 55 55 … … 60 60 61 61 == Changelog == 62 = 1.0.9 = 63 * Fixed times for most cities. 64 62 65 = 1.0.8 = 63 66 * Removed hacked code - reported to WordPress.org forums -
sunrise-sunset/trunk/sunrisesunset.php
r525899 r527059 4 4 Plugin URI: http://wordpress.org/extend/plugins/sunrise-sunset/ 5 5 Description: Displays Sunrise and Sunset Times 6 Version: 1.0.86 Version: 1.0.9 7 7 Author: Rex Posadas ([email protected]) 8 8 Author URI: http://www.rxnfx.com/ss-plugin … … 37 37 class sunrise_sunset extends WP_Widget 38 38 { 39 40 39 private $_cities; 41 private $_latitude;42 private $_longitude;43 40 44 41 private function populateCities() … … 47 44 foreach ($lines as $line) { 48 45 $pieces = explode(":", $line); 49 $this->_cities[$pieces[0]] = new City($pieces[0], $pieces[1], $pieces[2]); 46 if ($pieces[0] == 'city') continue; 47 $this->_cities[$pieces[0]] = new City($pieces[0], $pieces[1], $pieces[2], $pieces[3], $pieces[4]); 50 48 } 51 49 } … … 166 164 } 167 165 166 private function convertTimezone($timestamp, $city) 167 { 168 $newTimestamp = 0; 169 170 switch ($city->getTimezone()) { 171 case 'EST': 172 $newTimestamp = $timestamp - (5 * 60 * 60); 173 break; 174 case 'EDT': 175 $newTimestamp = $timestamp - (4 * 60 * 60); 176 break; 177 case 'MST': 178 $newTimestamp = $timestamp - (7 * 60 * 60); 179 break; 180 case 'CST': 181 $newTimestamp = $timestamp - (6 * 60 * 60); 182 break; 183 case 'CDT': 184 $newTimestamp = $timestamp - (5 * 60 * 60); 185 break; 186 case 'PST': 187 $newTimestamp = $timestamp - (8 * 60 * 60); 188 break; 189 case 'PDT': 190 $newTimestamp = $timestamp - (7 * 60 * 60); 191 break; 192 } 193 194 $time_format = 'h:i A'; 195 196 $olddate = date($time_format, $timestamp); 197 $newdate = date($time_format, $newTimestamp); 198 199 200 return $newTimestamp; 201 } 202 168 203 169 204 function ss_get_times($instance) 170 205 { 171 206 $time_format = 'h:i A'; 172 173 $lat = $this->_cities[$instance['city']]->getLatitude(); 174 $l ong = $this->_cities[$instance['city']]->getLongitude();175 176 // $suninfo = date_sun_info(time(), floatval($lat), floatval($long)); 177 $suninfo = date_sun_info(time(), floatval($long), floatval($lat));178 179 $sunrise_time = date($time_format, $ suninfo['sunrise']);180 $sunset_time = date($time_format, $ suninfo['sunset']);207 $targetCity = $this->_cities[$instance['city']]; 208 209 $lat = $targetCity->getLatitude(); 210 $long = $targetCity->getLongitude(); 211 212 $suninfo = date_sun_info(time(), $lat, $long); 213 214 $sunrise_time = date($time_format, $this->convertTimezone($suninfo['sunrise'], $targetCity)); 215 $sunset_time = date($time_format, $this->convertTimezone($suninfo['sunset'], $targetCity)); 181 216 182 217 return array('sunrise' => $sunrise_time, 'sunset' => $sunset_time);
Note: See TracChangeset
for help on using the changeset viewer.