Changeset 1641

Show
Ignore:
Timestamp:
08/31/05 10:17:19
Author:
miyagawa
Message:

Added 'date-timezone' configuration option, so it sets Date: header that Gmail can understand
It defaults to 'local' timezone of your machine if not set

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bloglines2email/trunk/bloglines2email

    r1640 r1641  
    11#!/usr/local/bin/perl -w 
    22use strict; 
     3use DateTime; 
     4use DateTime::Format::Mail; 
    35use Encode; 
    46use FindBin; 
     
    6971       $feed_title =~ tr/,//d; 
    7072    my $msg = MIME::Lite->new( 
     73        Date => get_rfc2822_date($cfg), 
    7174        From => encode('MIME-Header', qq("$feed_title" <$cfg->{mailfrom}>)), 
    7275        To   => $cfg->{mailto}, 
     
    8184} 
    8285 
     86sub get_rfc2822_date { 
     87    my $cfg = shift; 
     88    my $dt  = @_ 
     89        ? DateTime::Format::Mail->parse_datetime($_[0]) 
     90        : DateTime->now; 
     91    my $tz = $cfg->{'date-timezone'} || 'local'; 
     92    $dt->set_time_zone($tz); 
     93    DateTime::Format::Mail->format_datetime($dt); 
     94} 
     95 
    8396sub format_body { 
    8497    my($feed, $item, $cfg) = @_; 
     
    89102        item => $item, 
    90103        cfg  => $cfg, 
     104        get_rfc2822_date => sub { get_rfc2822_date($cfg, @_) }, 
    91105    }, \my $out); 
    92106    $out; 
     
    102116<div style="clear:both"></div> 
    103117<div[% UNLESS item.description.match('(?i)^<p[ >]') %] style="padding: 1em 0"[% END %]>[% item.description %]</div> 
    104 <div style="font-size:0.8em">[% IF item.pubDate %]Posted on [% item.pubDate %][% END %] | <a href="[% item.link | html %]">permalink</a> | <a href="[% feed.link | html %]">[% feed.title | html %]</a></div> 
     118<div style="font-size:0.8em">[% IF item.pubDate %]Posted on [% get_rfc2822_date(item.pubDate) %][% END %] | <a href="[% item.link | html %]">permalink</a> | <a href="[% feed.link | html %]">[% feed.title | html %]</a></div> 
    105119</div> 
    106120HTML 
  • bloglines2email/trunk/bloglines2email.conf.sample

    r1638 r1641  
    44mailfrom: mail-address@exapmle.com 
    55group-items: 1 
     6date-timezone: Asia/Tokyo