Changeset 74

Show
Ignore:
Timestamp:
06/26/07 10:32:17 (19 months ago)
Author:
verbosus
Message:

Removed date_create/DateTime dependency

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • hacks/trunk/feedphp/feed.php

    r72 r74  
    66   *  
    77   * author: Antonio Cavedoni <http://cavedoni.com/> 
    8    * version: 0.12 
     8   * version: 0.2 
    99   * revision: $Id$ 
    1010   * license: BSD 
     
    110110    public function addItem($params)  
    111111    { 
     112        if (strlen($params['pubDate']) == 10) { 
     113            // yyyy-mm-dd 
     114            $d = strptime($params['pubDate'], "%Y-%m-%d"); 
     115        } else if (strlen($params['pubDate']) == 19) { 
     116            // yyyy-mm-dd hh:mm:ss 
     117            $d = strptime($params['pubDate'], "%Y-%m-%d %H:%M:%S");             
     118        } 
     119 
     120        $itemDate = mktime( 
     121            $d['tm_hour'],  
     122            $d['tm_min'], 
     123            $d['tm_sec'], 
     124            $d['tm_mon'], 
     125            $d['tm_mday'], 
     126            $d['tm_year'] 
     127        ); 
     128 
    112129        $item = array( 
    113130            'title' => $params['title'],  
    114131            'link' => $params['link'],  
    115132            'description' => $params['description'],  
    116             'pubDate' => date_create($params['pubDate']) 
     133            'pubDate' => $itemDate 
    117134        ); 
    118135 
     
    136153    public function rfc3339Date($date)  
    137154    { 
    138         return $date->format('Y-m-d\TH:i:s\Z'); 
     155        return date('Y-m-d\TH:I:S\Z', $date); 
    139156    } 
    140157 
    141158    public function rfc2822Date($date)  
    142159    { 
    143         return $date->format('r'); 
     160        return date('r', $date); 
    144161    } 
    145162 
     
    222239    {  
    223240        header('Content-type: '. $this->mimeType .'; charset='. $this->charset); 
    224         $this->doConditionalGet($this->latestPostDate()->format('U')); 
     241        $this->doConditionalGet(date('U', $this->latestPostDate())); 
    225242        print $this->write(); 
    226243    } 
     
    304321            $this->writer->writeElement('pubDate',  
    305322                $this->rfc2822Date($item['pubDate'])); 
    306             if ($item['author']) { 
     323            if (array_key_exists('author', $item)) { 
    307324                $this->writer->writeElement('author',  
    308325                    "{$item['authorEmail']} ({$item['author']})");