Changeset 2062

Show
Ignore:
Timestamp:
02/11/09 17:49:51
Author:
charsbar
Message:

::CustomFeed?::MixiScraper?: add ' 00:00' before parsing datetime if necessary (spotted by id:mad-capone)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/CustomFeed/MixiScraper.pm

    r2061 r2062  
    152152my $format = DateTime::Format::Strptime->new(pattern => '%Y-%m-%d %H:%M'); 
    153153 
     154sub parse_date { 
     155    my ($self, $datetime) = @_; 
     156 
     157    # Calendar doesn't have %H:%M part (spotted by id:mad-capone) 
     158    return unless defined $datetime; 
     159    $datetime .= ' 00:00' unless $datetime =~ /\d+:\d+$/; 
     160 
     161    Plagger::Date->parse($format, $datetime); 
     162} 
     163 
    154164sub add_entry { 
    155165    my ($self, $context, $type, $feed, $msg) = @_; 
     
    163173    $entry->link($msg->{link}); 
    164174    $entry->author($msg->{name}); 
    165     $entry->date( Plagger::Date->parse($format, $msg->{time}) ); 
     175    $entry->date( $self->parse_date($msg->{time}) ); 
    166176    $entry->date->set_time_zone('Asia/Tokyo') if $entry->date; 
    167177 
     
    220230            $entry->body($body); 
    221231 
    222             $entry->date( Plagger::Date->parse($format, $item->{time}) ); 
     232            $entry->date( $self->parse_date($item->{time}) ); 
    223233            $entry->date->set_time_zone('Asia/Tokyo') if $entry->date; 
    224234            if ($self->conf->{fetch_comment}) { 
     
    229239                     $c->link($comment->{link}); 
    230240                     $c->author($comment->{name}); 
    231                      $c->date( Plagger::Date->parse($format, $comment->{time}) ); 
     241                     $c->date( $self->parse_date($comment->{time}) ); 
    232242                     $c->date->set_time_zone('Asia/Tokyo') if $c->date; 
    233243                  push @comments, $c;