CVS: phpweather data_retrieval.php,1.37,1.38 phpweather.php,1.37,1.38
Brought to you by:
iridium
|
From: Martin G. <gim...@us...> - 2004-01-03 19:05:18
|
Update of /cvsroot/phpweather/phpweather
In directory sc8-pr-cvs1:/tmp/cvs-serv27919
Modified Files:
data_retrieval.php phpweather.php
Log Message:
This restores the null and mysql database backends to working
order... let's hope they stay that way.
Index: data_retrieval.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/data_retrieval.php,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- data_retrieval.php 3 Jan 2004 10:51:49 -0000 1.37
+++ data_retrieval.php 3 Jan 2004 19:05:15 -0000 1.38
@@ -24,7 +24,7 @@
* @see set_metar()
*/
var $metar;
- var $metar_time;
+ //var $metar_time;
var $metar_arch;
/**
@@ -67,9 +67,8 @@
$this->set_icao($this->properties['icao']);
$this->metar = false;
- $this->metar_time = false;
+ //$this->metar_time = false;
$this->metar_arch = false;
- $this->fd = false;
$this->time_from = false;
$this->time_to = false;
@@ -105,7 +104,7 @@
$this->properties['icao'] = strtoupper($new_icao);
$this->icao_data = false;
$this->metar = false;
- $this->metar_time = false;
+ //$this->metar_time = false;
$this->decoded_metar = false;
$this->metar_arch = false;
$this->taf = false;
@@ -292,7 +291,7 @@
*/
$tmp_metar = $metar;
$this->metar = $metar;
- $this->metar_time = $time;
+ //$this->metar_time = $time;
if ($this->properties['always_use_db'] ||
$timestamp > time() - $this->properties['cache_timeout']) {
@@ -419,21 +418,21 @@
}
/* side effect */
- $metar_time = $date[0].$date[1].$date[2].$date[3].$date[4]."00";
+ //$metar_time = $date[0].$date[1].$date[2].$date[3].$date[4]."00";
/* We then cache the METAR in our database */
if ($new_station) {
$this->debug('get_metar_from_web(): Inserting new METAR for <code>' .
$this->get_location() . '</code>');
- $this->db->insert_metar($icao, $metar, $timestamp, $metar_time);
+ $this->db->insert_metar($icao, $metar, $timestamp);
} else {
$this->debug('get_metar_from_web(): Updating METAR for <code>' .
$this->get_location() . '</code>');
- $this->db->update_metar($icao, $metar, $timestamp, $metar_time);
+ $this->db->update_metar($icao, $metar, $timestamp);
}
/* We update and return the METAR */
$this->metar = $metar;
- $this->metar_time = $metar_time;
+ //$this->metar_time = $metar_time;
return $metar;
}
Index: phpweather.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/phpweather.php,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- phpweather.php 2 Oct 2003 22:54:46 -0000 1.37
+++ phpweather.php 3 Jan 2004 19:05:15 -0000 1.38
@@ -178,12 +178,12 @@
/* Setup other variables */
if ($index===false) { /* We are getting the current METAR */
$decoded_metar['metar'] = $tmp_metar;
- $decoded_metar['time'] = $this->metar_time;
+ //$decoded_metar['time'] = $this->metar_time;
}
else {
if ($this->metar_arch===false) { /* error */
return false;
- }
+ }
$tmp_metar = $this->metar_arch[$index]['metar'];
$decoded_metar['metar'] = $tmp_metar;
$decoded_metar['time'] = $this->metar_arch[$index]['time'];
@@ -226,34 +226,30 @@
*
* We return a standard Unix UTC/GMT timestamp suitable for
* gmdate().
- * Due to a bug in PHP, on some systems the time reported may
- * be incorrect. If you experience this, you can set
- * $this->properties['offset'] to be the offset to add. For
- * example, if your times generated are 1 hour too early (so
- * metars appear an hour older than they are), set
- * $this->properties['offset'] to be +1 in your defaults.php
- * file.
+ *
+ * If you experience incorrect timestamps but cannot set the
+ * clock, then you can set $this->properties['offset'] to be
+ * the offset in hours to add. For example, if your times
+ * generated are 1 hour too early (so METARs appear an hour
+ * older than they are), set $this->properties['offset'] to be
+ * +1 in your defaults.php file.
*/
- /* We get the report time from elsewhere */
-// $decoded_metar['time'] = $this->metar_time;
+ if ($regs[1] > gmdate('j')) {
+ /* The day is greather that the current day of month => the
+ * report is from last month.
+ */
+ $month = gmdate('n') - 1;
+ } else {
+ $month = gmdate('n');
+ }
-// if ($regs[1] > gmdate('j')) {
-// /* The day is greather that the current day of month => the
-// * report is from last month.
-// */
-// $month = gmdate('n') - 1;
-// } else {
-// $month = gmdate('n');
-// }
-// /* is this really useful? let's put this in a readable timestamp... */
-// $decoded_metar['time'] =
-// gmmktime($regs[2] + $this->properties['offset'],
-// $regs[3], 0, $month, $regs[1], gmdate('Y'));
+ $decoded_metar['time'] =
+ gmmktime($regs[2] + $this->properties['offset'],
+ $regs[3], 0, $month, $regs[1], gmdate('Y'));
} elseif (ereg('(AUTO|COR|RTD|CC[A-Z]|RR[A-Z])', $part, $regs)) {
-
/*
* Report Modifier: AUTO, COR, CCx or RRx
*/
|