Update of /cvsroot/phpweather/phpweather
In directory sc8-pr-cvs1:/tmp/cvs-serv15950
Modified Files:
data_retrieval.php
Log Message:
Reindention --- I read through the code and expanded a comment to
better document the behavious or gmmktime.
Index: data_retrieval.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/data_retrieval.php,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -3 -r1.36 -r1.37
--- data_retrieval.php 30 Dec 2003 16:01:40 -0000 1.36
+++ data_retrieval.php 3 Jan 2004 10:51:49 -0000 1.37
@@ -280,7 +280,6 @@
}
$tmp_metar = false;
- $tmp_metar_time = false;
if ($data = $this->db->get_metar($this->get_icao())) { /* found station */
$this->debug('get_metar_from_db(): Found the METAR in the database');
@@ -298,7 +297,7 @@
if ($this->properties['always_use_db'] ||
$timestamp > time() - $this->properties['cache_timeout']) {
/* We have asked explicit for a cached METAR, or the METAR is
- * still fresh.Either way - we return the METAR we found in
+ * still fresh. Either way - we return the METAR we found in
* the database.
*/
$this->debug('get_metar_from_db(): Using previously cached METAR for <code>' .
@@ -324,11 +323,13 @@
/* Now we can get the archive METARs. */
$this->metar_arch = false;
- if ($this->time_from!==false) {
- if ($data = $this->db->get_metar($this->get_icao(),$this->time_from,$this->time_to)) {
- for($i=0;$i<count($data);$i++) {
- $this->metar_arch[$i] = array('metar'=>$data[$i][0],
- 'time'=>$data[$i][2]);
+ if ($this->time_from !== false) {
+ if ($data = $this->db->get_metar($this->get_icao(),
+ $this->time_from,
+ $this->time_to)) {
+ for($i = 0; $i < count($data); $i++) {
+ $this->metar_arch[$i] = array('metar' => $data[$i][0],
+ 'time' => $data[$i][2]);
}
}
}
@@ -376,7 +377,10 @@
$date = explode(':', strtr($date, '/ ', '::'));
if ($date[2] > gmdate('j')) {
/* The day is greater that the current day of month. This
- * implies, that the report is from last month.
+ * implies, that the report is from last month. Luckily the
+ * gmmktime function can deal with the month being zero, it
+ * will then interpret it as December the previous year which
+ * is exactly what we want.
*/
$date[1]--;
}
|