Changeset 1754

Show
Ignore:
Timestamp:
10/15/06 17:39:24
Author:
miyagawa
Message:

GuessTimeZoneByDomain?: guess TZ if date is set UTC. Fixes #426

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Filter/GuessTimeZoneByDomain.pm

    r1750 r1754  
    3838    my($self, $context, $args) = @_; 
    3939 
    40     return unless $args->{entry}->date && $args->{entry}->date->time_zone->is_floating; 
     40    return unless $args->{entry}->date && 
     41        ($args->{entry}->date->time_zone->is_floating || $args->{entry}->date->time_zone->name eq 'UTC'); 
    4142 
    4243    my $uri = URI->new($args->{entry}->permalink); 
     
    7778=head1 NAME 
    7879 
    79 Plagger::Plugin::Filter::GuessTimeZoneByDomain - Guess timezone by domains if datetime is floating 
     80Plagger::Plugin::Filter::GuessTimeZoneByDomain - Guess timezone by domains if datetime is floating or UTC 
    8081 
    8182=head1 SYNOPSIS 
     
    8687 
    8788This plugin guesses feed date timezone by domains, if dates are 
    88 floating. It uses the mapping table from ISO 3166 country code to 
     89floating or UTC. It uses the mapping table from ISO 3166 country code to 
    8990timezones available in Olson database (hence requires 
    9091DateTime::TimeZone 0.51). 
     
    9495of its domain name (ccTLD). 
    9596 
    96 For example, if the datetime is floating in the feed of I<example.jp>, 
    97 it is resolved to I<Asia/Tokyo> since its ccTLD is I<jp>. In the case 
    98 of I<www.asahi.com>, ccTLD is null but the IP address is assigned to 
    99 Japan, hence it is resolved to I<Asia/Tokyo> as well. 
     97For example, if the datetime is floating or UTC set in the feed of 
     98I<example.jp>, it is resolved to I<Asia/Tokyo> since its ccTLD is 
     99I<jp>. In the case of I<www.asahi.com>, ccTLD is null but the IP 
     100address is assigned to Japan, hence it is resolved to I<Asia/Tokyo> as 
     101well. 
    100102 
    101103=head1 CONFIG 
  • trunk/plagger/t/plugins/Filter-GuessTimeZoneByDomain/base.t

    r1748 r1754  
    9191is $context->update->feeds->[0]->entries->[0]->date->time_zone->name, "America/New_York"; 
    9292 
     93=== Force upgrade GMT 
     94--- input config 
     95plugins: 
     96  - module: CustomFeed::Debug 
     97    config: 
     98      title: Foo 
     99      entry: 
     100        - link: http://bulknews.net/ 
     101          date: 2006/10/14 12:00:00 GMT 
     102  - module: Filter::GuessTimeZoneByDomain 
     103    config: 
     104      conflict_policy: ip 
     105--- expected 
     106is $context->update->feeds->[0]->entries->[0]->date->time_zone->name, "Asia/Tokyo"; 
     107is $context->update->feeds->[0]->entries->[0]->date->iso8601, "2006-10-14T21:00:00"; 
     108