Thread: Help
Brought to you by:
iridium
From: Michael <din...@ea...> - 2002-08-06 23:22:45
|
I have installed phpweather-CVS-latest, read the docs, and for one i = dont see a demo.php file, i have however configured all my settings and = setup my sql DB. Now if i want to show the latest METAR for lets say = KLAX on a page i build, what is the code to call for that? Any help is appreciated Michael |
From: Jake O. <ja...@or...> - 2002-08-06 23:36:12
|
This is probably a fairly stupid question that hopefully has a simple fix. I'm running a version of 2.0 on my site (I think it's a pre-2.0 final CVS release, so if it's been fixed in the final release, let me know). It provides the simple current weather for the area for our rental guests (http://www.sunrayinc.com/sunriver/weather/) using a modified print_table function. However, as you'll see right now, it's showing a nighttime part-cloud graphic, even though it's only 4:30 here right now. I tried setting the time offset before, and it didn't work (or maybe I didn't set it right?). Any body have any ideas? -jake |
From: Martin G. <gim...@gi...> - 2002-08-08 10:34:24
|
"Jake Ortman" <ja...@or...> writes: > This is probably a fairly stupid question that hopefully has a simple fix. With PHP Weather there's no such thing as a stupid question - new problems surface regularly... :-) > I'm running a version of 2.0 on my site (I think it's a pre-2.0 > final CVS release, so if it's been fixed in the final release, let > me know). There has not been a release of the 2.0 code yet, although it's the code that I'm using at gimpster.com and at phpweather.net... > It provides the simple current weather for the area for our rental > guests (http://www.sunrayinc.com/sunriver/weather/) using a modified > print_table function. However, as you'll see right now, it's showing > a nighttime part-cloud graphic, even though it's only 4:30 here > right now. I tried setting the time offset before, and it didn't > work (or maybe I didn't set it right?). No, it's not your fault - it's a problem in pw_images.php at line 266: } elseif (ereg('([0-9]{2})([0-9]{2})([0-9]{2})Z', $part, $regs)) { if (($regs[2] < 6) || ($regs[2] > 18)) { $night = 1; } The regular expression matches the date-part of the METAR and the if-statement in the next line tries to figure out if it's night or day... The problem is, that this is calculated using UTC time: a report made at 16:30 PDT in Oregon (the afternoon) is made at 23:30 UTC which is night-time according to the if-statement above. > Any body have any ideas? Yes, change the test so that it's correct for your timezone. Use if (($regs[2] > 1) && ($regs[2] < 13)) { $night = 1; } instead - that should be correct for the Pacific Time Zone. This could probably be automated using date('Z')... -- Martin Geisler My GnuPG Key: 0xF7F6B57B See http://gimpster.com/ and http://phpweather.net/ for: PHP Weather => Shows the current weather on your webpage and PHP Shell => A telnet-connection (almost :-) in a PHP page. |
From: Jake O. <ja...@or...> - 2002-08-08 18:33:14
|
>Yes, change the test so that it's correct for your timezone. Use > > if (($regs[2] > 1) && ($regs[2] < 13)) { > $night = 1; > } That didn't work. It's 11:30 am pacific time right now, and there's a moon graphic on the site :-). -Jake |
From: Martin G. <gim...@gi...> - 2002-08-13 09:31:02
|
"Jake Ortman" <ja...@or...> writes: >>Yes, change the test so that it's correct for your timezone. Use >> >> if (($regs[2] > 1) && ($regs[2] < 13)) { >> $night = 1; >> } > > That didn't work. It's 11:30 am pacific time right now, and there's > a moon graphic on the site :-). Hmm, that's odd. Let me try and explain how I came up with '> 1' and '< 13'. The Pacific Time Zone is UTC - 7 hours because of Daylight Saving Time, correct me if I'm wrong, I've got my information from this page: http://www.timetemperature.com/tzus/oregon_time_zone.shtml So a timeline would look like this: PDT: 00 ~~~~~~ 06 ------ 12 ------ 18 ~~~~~~ 24 where the ~ marks the hours that belong to the night. The corresponding UTC timezone is: UTC: 07 ~~~~~~ 13 ------ 19 ------ 01 ~~~~~~ 07 So, this means that it's night at your place when the hour is between 7 and 13 UTC or 1 and 7 UTC, i.e., from 1 to 13 UTC. So unless someone can find an error in the above calculations, then I cannot understand why it doesn't work for you... -- Martin Geisler My GnuPG Key: 0xF7F6B57B See http://gimpster.com/ and http://phpweather.net/ for: PHP Weather => Shows the current weather on your webpage and PHP Shell => A telnet-connection (almost :-) in a PHP page. |
From: Martin G. <gim...@gi...> - 2002-08-07 14:41:44
|
"Michael" <din...@ea...> writes: > I have installed phpweather-CVS-latest, read the docs, and for one i > dont see a demo.php file, Ups - the docs are outdated... > i have however configured all my settings and setup my sql DB. Now > if i want to show the latest METAR for lets say KLAX on a page i > build, what is the code to call for that? This should give you the report: <?php require('phpweather.php'); require('output/pw_text_en.php'); require('output/pw_images.php'); $weather = new phpweather(array('icao' => 'KLAX')); $text = new pw_text_en($weather); $icons = new pw_images($weather); echo $text->print_pretty() . "<br />\n"; echo '<img src="'.$icons->get_sky_image().'" />'; echo '<img src="'.$icons->get_winddir_image().'" />'; echo '<img src="'.$icons->get_temp_image().'" />'; ?> -- Martin Geisler My GnuPG Key: 0xF7F6B57B See http://gimpster.com/ and http://phpweather.net/ for: PHP Weather => Shows the current weather on your webpage and PHP Shell => A telnet-connection (almost :-) in a PHP page. |