summaryrefslogtreecommitdiff
path: root/fml/lib
diff options
context:
space:
mode:
authorfukachan <fukachan>2003-07-21 10:37:12 +0000
committerfukachan <fukachan>2003-07-21 10:37:12 +0000
commitabb87ebf2e413f500648cd38c5d22df15c62bdd7 (patch)
tree15798d31447f2d6297d38db1e3e4812ba7b8ea53 /fml/lib
parenta85de35fc6dcd6c0ade02d04f688483c7c5b9c0b (diff)
downloadfml8-abb87ebf2e413f500648cd38c5d22df15c62bdd7.tar.gz
fml8-abb87ebf2e413f500648cd38c5d22df15c62bdd7.tar.bz2
fml8-abb87ebf2e413f500648cd38c5d22df15c62bdd7.zip
method-ify date_to_unixtime() of Mail::Message::Date.
Diffstat (limited to 'fml/lib')
-rw-r--r--fml/lib/FML/Article/Summary.pm5
-rw-r--r--fml/lib/Mail/Message/Date.pm77
-rw-r--r--fml/lib/Mail/ThreadTrack/Analyze.pm5
3 files changed, 42 insertions, 45 deletions
diff --git a/fml/lib/FML/Article/Summary.pm b/fml/lib/FML/Article/Summary.pm
index 3fbe99ac..2ff42001 100644
--- a/fml/lib/FML/Article/Summary.pm
+++ b/fml/lib/FML/Article/Summary.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Summary.pm,v 1.10 2003/02/16 08:48:05 fukachan Exp $
+# $FML: Summary.pm,v 1.11 2003/03/14 06:54:51 fukachan Exp $
#
package FML::Article::Summary;
@@ -99,7 +99,8 @@ sub _prepare_info
my $header = $msg->whole_message_header();
my $address = $header->get( 'from' ) || '';
my $date = $header->get( 'date' ) || '';
- my $unixtime = Mail::Message::Date::date_to_unixtime( $date );
+ my $obj = new Mail::Message::Date;
+ my $unixtime = $obj->date_to_unixtime( $date );
# log the first 15 bytes of user@domain in From: header field.
if (defined $address) {
diff --git a/fml/lib/Mail/Message/Date.pm b/fml/lib/Mail/Message/Date.pm
index 819e6c51..4ad54071 100644
--- a/fml/lib/Mail/Message/Date.pm
+++ b/fml/lib/Mail/Message/Date.pm
@@ -2,7 +2,7 @@
#
# Copyright (C) 2000,2001,2002,2003 Ken'ichi Fukamachi
#
-# $FML: Date.pm,v 1.19 2003/01/26 03:23:10 fukachan Exp $
+# $FML: Date.pm,v 1.20 2003/03/14 06:53:01 fukachan Exp $
#
package Mail::Message::Date;
@@ -279,29 +279,19 @@ sub _log
# Descriptions: convert Date: string to UNIXTIME (sec)
-# Arguments: STR($in)
+# Arguments: OBJ($self) STR($in)
# Side Effects: none
# Return Value: NUM(unix time)
sub date_to_unixtime
{
- my ($in) = @_;
- my ($input) = $in;
- my ($day, $month, $year, $hour, $min, $sec, $pm);
- my ($shift, $shift_t, $shift_m);
- my (%month);
- my ($zone);
-
- # cheap sanity, but ok?;)
+ my ($self, $in) = @_;
+ my ($day, %month, $month, $year, $hour, $min, $sec, $pm, $zone,
+ $shift, $shift_t, $shift_m);
+
+ # cheap sanity, but "return 0" is ok?;)
return 0 unless defined $in;
return 0 unless $in;
- # XXX-TODO: method-ify date_to_unixtime() ?
- # XXX-TODO: more documents
-
- $in =~ s/[\s\n]*$//;
-
- require 'timelocal.pl';
-
# hints
my $c = 1;
for my $month ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
@@ -309,6 +299,9 @@ sub date_to_unixtime
$month{ $month } = $c++;
}
+ # $in = clean up-ed string. $input = original one.
+ my $input = $in;
+ $in =~ s/[\s\n]*$//;
if ($in =~ /([A-Z]+)\s*$/) {
$zone = $1;
if ($zone{$zone} ne "") {
@@ -332,15 +325,15 @@ sub date_to_unixtime
if ($in =~
/(\d+)\s+(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+([\+\-])(\d\d)(\d\d)/) {
if ($debug_mti) { print STDERR "Date2UnixTime: Standard\n";}
- $day = $1;
- $month = ($month{$2} || $month) - 1;
- $year = $3 > 1900 ? $3 - 1900 : $3;
- $hour = $4;
- $min = $5;
- $sec = $6;
+ $day = $1;
+ $month = ($month{$2} || $month) - 1;
+ $year = $3 > 1900 ? $3 - 1900 : $3;
+ $hour = $4;
+ $min = $5;
+ $sec = $6;
# time zone
- $pm = $7;
+ $pm = $7;
$shift_t = $8;
$shift_m = $9;
}
@@ -350,15 +343,15 @@ sub date_to_unixtime
print STDERR "Date2UnixTime: Standard without \$sec\n";
}
- $day = $1;
- $month = ($month{$2} || $month) - 1;
- $year = $3 > 1900 ? $3 - 1900 : $3;
- $hour = $4;
- $min = $5;
- $sec = 0;
+ $day = $1;
+ $month = ($month{$2} || $month) - 1;
+ $year = $3 > 1900 ? $3 - 1900 : $3;
+ $hour = $4;
+ $min = $5;
+ $sec = 0;
# time zone
- $pm = $6;
+ $pm = $6;
$shift_t = $7;
$shift_m = $8;
}
@@ -366,15 +359,15 @@ sub date_to_unixtime
# no timezone case ... WHAT SHOULD WE DO ? ;_;
elsif ($in =~ /([A-Za-z]+)\s+(\d{1,2})\s+(\d+):(\d+):(\d+)\s+(\d{4})\s*/) {
if ($debug_mti) { print STDERR "Date2UnixTime: Japan specific?\n";}
- $month = ($month{$1} || $month) - 1;
- $day = $2;
- $hour = $3;
- $min = $4;
- $sec = $5;
- $year = $6 > 1900 ? $6 - 1900 : $6;
+ $month = ($month{$1} || $month) - 1;
+ $day = $2;
+ $hour = $3;
+ $min = $4;
+ $sec = $5;
+ $year = $6 > 1900 ? $6 - 1900 : $6;
# time zone
- $pm = '+';
+ $pm = '+';
$shift_t = '09';
$shift_m = '00';
}
@@ -398,13 +391,15 @@ sub date_to_unixtime
return 0;
}
- # get gmtime
+ # calculate shift between local time and UTC
$shift_t =~ s/^0*//;
$shift_m =~ s/^0*//;
$shift_m = 0 unless $shift_m;
+ $shift = $shift_t + ($shift_m/60);
+ $shift = ($pm eq '+' ? -1 : +1) * $shift;
- $shift = $shift_t + ($shift_m/60);
- $shift = ($pm eq '+' ? -1 : +1) * $shift;
+ # conversion to gmtime (UTC)
+ require 'timelocal.pl';
if ($debug_mti) {
print STDERR
diff --git a/fml/lib/Mail/ThreadTrack/Analyze.pm b/fml/lib/Mail/ThreadTrack/Analyze.pm
index be113419..14638778 100644
--- a/fml/lib/Mail/ThreadTrack/Analyze.pm
+++ b/fml/lib/Mail/ThreadTrack/Analyze.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Analyze.pm,v 1.29 2002/12/22 03:20:44 fukachan Exp $
+# $FML: Analyze.pm,v 1.30 2002/12/24 10:19:49 fukachan Exp $
#
package Mail::ThreadTrack::Analyze;
@@ -552,7 +552,8 @@ sub _speculate_time
if (defined $header->get('date')) {
use Mail::Message::Date;
- return Mail::Message::Date::date_to_unixtime($header->get('date'));
+ my $obj = new Mail::Message::Date;
+ return $obj->date_to_unixtime($header->get('date'));
}
else {
return time;