| @@ -10,9 +10,9 @@ | ||
| 10 | 10 | function FeedTime ($time) { |
| 11 | 11 | $this->set($time); |
| 12 | 12 | } /* FeedTime constructor */ |
| 13 | 13 | |
| 14 | - function set ($time) { | |
| 14 | + function set ($time, $recurse = false) { | |
| 15 | 15 | $this->rep = $time; |
| 16 | 16 | $this->ts = NULL; |
| 17 | 17 | if (is_numeric($time)) : // Presumably a Unix-epoch timestamp |
| 18 | 18 | $this->ts = $this->rep; |
| @@ -22,9 +22,9 @@ | ||
| 22 | 22 | |
| 23 | 23 | if ($this->failed()) : |
| 24 | 24 | // In some versions of PHP, strtotime() does not support |
| 25 | 25 | // the UT timezone. Since UT is by definition within 1 |
| 26 | - // second of UTC, we'll just convert it here to avoid | |
| 26 | + // second of UTC, we'll just convert it preemptively to avoid | |
| 27 | 27 | // problems. |
| 28 | 28 | $time = preg_replace( |
| 29 | 29 | '/(\s)UT$/', |
| 30 | 30 | '$1UTC', |
| @@ -30,8 +30,14 @@ | ||
| 30 | 30 | '$1UTC', |
| 31 | 31 | $time |
| 32 | 32 | ); |
| 33 | 33 | $this->ts = strtotime($time); |
| 34 | + | |
| 35 | + if ($this->failed() | |
| 36 | + and preg_match('/^(.*)([+\-][0-9]+|\s+[A-Za-z]{1,3})$/', $time, $matches)) : | |
| 37 | + // Try dropping the time zone and recurse | |
| 38 | + $this->set($matches[1], /*recurse=*/ true); | |
| 39 | + endif; | |
| 34 | 40 | endif; |
| 35 | 41 | endif; |
| 36 | 42 | } /* FeedTime::set() */ |
| 37 | 43 | |
| @@ -102,15 +108,19 @@ | ||
| 102 | 108 | $offset = 0; |
| 103 | 109 | if ( isset($match[15]) and $match[15] == 'Z' ) : |
| 104 | 110 | # zulu time, aka GMT |
| 105 | 111 | else : |
| 106 | - $tz_mod = $match[12]; | |
| 107 | - $tz_hour = $match[13]; | |
| 108 | - $tz_min = $match[14]; | |
| 112 | + $tz_mod = (isset($match[12]) ? $match[12] : NULL); | |
| 113 | + $tz_hour = (isset($match[13]) ? $match[13] : NULL); | |
| 114 | + $tz_min = (isset($match[14]) ? $match[14] : NULL); | |
| 109 | 115 | |
| 110 | 116 | # zero out the variables |
| 111 | - if ( ! $tz_hour ) { $tz_hour = 0; } | |
| 112 | - if ( ! $tz_min ) { $tz_min = 0; } | |
| 117 | + if ( is_null($tz_hour) ) : | |
| 118 | + $offset = (int) get_option('gmt_offset'); | |
| 119 | + $tz_hour = abs($offset); | |
| 120 | + $tz_mod = ((abs($offset) != $offset) ? '-' : '+'); | |
| 121 | + endif; | |
| 122 | + if ( is_null($tz_min) ) : $tz_min = 0; endif; | |
| 113 | 123 | |
| 114 | 124 | $offset_secs = (($tz_hour*60)+$tz_min)*60; |
| 115 | 125 | |
| 116 | 126 | # is timezone ahead of GMT? then subtract offset |