Re: Night Time Images
Brought to you by:
iridium
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. |