r3444 - in /packages/libemail-date-perl: ./ branches/
branches/upstream/
branches/upstream/current/ branches/upstream/current/lib/
branches/upstream/current/lib/Email/ branches/upstream/current/t/ tags/
pabs-guest at users.alioth.debian.org
pabs-guest at users.alioth.debian.org
Sat Aug 12 08:12:07 UTC 2006
Author: pabs-guest
Date: Sat Aug 12 08:12:05 2006
New Revision: 3444
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=3444
Log:
[svn-inject] Installing original source of libemail-date-perl
Added:
packages/libemail-date-perl/
packages/libemail-date-perl/branches/
packages/libemail-date-perl/branches/upstream/
packages/libemail-date-perl/branches/upstream/current/
packages/libemail-date-perl/branches/upstream/current/Changes
packages/libemail-date-perl/branches/upstream/current/MANIFEST
packages/libemail-date-perl/branches/upstream/current/META.yml
packages/libemail-date-perl/branches/upstream/current/Makefile.PL
packages/libemail-date-perl/branches/upstream/current/README
packages/libemail-date-perl/branches/upstream/current/lib/
packages/libemail-date-perl/branches/upstream/current/lib/Email/
packages/libemail-date-perl/branches/upstream/current/lib/Email/Date.pm
packages/libemail-date-perl/branches/upstream/current/t/
packages/libemail-date-perl/branches/upstream/current/t/test.t
packages/libemail-date-perl/tags/
Added: packages/libemail-date-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-date-perl/branches/upstream/current/Changes?rev=3444&op=file
==============================================================================
--- packages/libemail-date-perl/branches/upstream/current/Changes (added)
+++ packages/libemail-date-perl/branches/upstream/current/Changes Sat Aug 12 08:12:05 2006
@@ -1,0 +1,11 @@
+1.03 2004-09-23
+
+ - Email::Abstract is not required, and is only loaded when needed.
+
+1.02 2004-07-25
+
+ - s/gmtime/localtime/
+
+1.01 2004-07-17
+
+ - Initial Revision.
Added: packages/libemail-date-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-date-perl/branches/upstream/current/MANIFEST?rev=3444&op=file
==============================================================================
--- packages/libemail-date-perl/branches/upstream/current/MANIFEST (added)
+++ packages/libemail-date-perl/branches/upstream/current/MANIFEST Sat Aug 12 08:12:05 2006
@@ -1,0 +1,7 @@
+Changes
+lib/Email/Date.pm
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
+t/test.t
Added: packages/libemail-date-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-date-perl/branches/upstream/current/META.yml?rev=3444&op=file
==============================================================================
--- packages/libemail-date-perl/branches/upstream/current/META.yml (added)
+++ packages/libemail-date-perl/branches/upstream/current/META.yml Sat Aug 12 08:12:05 2006
@@ -1,0 +1,15 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Email-Date
+version: 1.03
+version_from: lib/Email/Date.pm
+installdirs: site
+requires:
+ Date::Parse: 2.27
+ Email::Simple: 1.9
+ Test::More: 0.47
+ Time::Local: 1.07
+ Time::Piece: 1.08
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
Added: packages/libemail-date-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-date-perl/branches/upstream/current/Makefile.PL?rev=3444&op=file
==============================================================================
--- packages/libemail-date-perl/branches/upstream/current/Makefile.PL (added)
+++ packages/libemail-date-perl/branches/upstream/current/Makefile.PL Sat Aug 12 08:12:05 2006
@@ -1,0 +1,15 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile (
+ AUTHOR => 'Casey West <casey at geeknest.com>',
+ ABSTRACT => "Find and Format Date Headers",
+ NAME => 'Email::Date',
+ PREREQ_PM => {
+ 'Date::Parse' => '2.27',
+ 'Email::Simple' => '1.9',
+ 'Test::More' => '0.47',
+ 'Time::Local' => '1.07',
+ 'Time::Piece' => '1.08',
+ },
+ VERSION_FROM => 'lib/Email/Date.pm',
+ );
Added: packages/libemail-date-perl/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-date-perl/branches/upstream/current/README?rev=3444&op=file
==============================================================================
--- packages/libemail-date-perl/branches/upstream/current/README (added)
+++ packages/libemail-date-perl/branches/upstream/current/README Sat Aug 12 08:12:05 2006
@@ -1,0 +1,59 @@
+NAME
+ Email::Date - Find and Format Date Headers
+
+SYNOPSIS
+ use Email::Date;
+
+ my $email = join '', <>;
+ my $date = find_date($email);
+ print $date->ymd;
+
+ my $header = format_date($date->epoch);
+
+ Email::Simple->create(
+ header => [
+ Date => $header,
+ ],
+ body => '...',
+ );
+
+DESCRIPTION
+ RFC 2822 defines the "Date:" header. It declares the header a required
+ part of an email message. The syntax for date headers is clearly laid
+ out. Stil, even a perfectly planned world has storms. The truth is, many
+ programs get it wrong. Very wrong. Or, they don't include a "Date:"
+ header at all. This often forces you to look elsewhere for the date, and
+ hoping to find something.
+
+ For this reason, the tedious process of looking for a valid date has
+ been encapsulated in this software. Further, the process of creating RFC
+ compliant date strings is also found in this software.
+
+ Functions
+ find_date
+ my $time_piece = find_date $email;
+
+ "find_date" accepts an email message in any format Email::Abstract
+ can understand. It looks through the email message and finds a date,
+ converting it to a Time::Piece object.
+
+ format_date
+ my $date = format_date; # now
+ my $date = format_date( time - 60*60 ); # one hour ago
+
+ "format_date" accepts an epoch value, such as the one returned by
+ "time". It returns a string representing the date and time of the
+ input, as specified in RFC 2822. If no input value is provided, the
+ current value of "time" is used.
+
+SEE ALSO
+ Email::Abstract, Time::Piece, Date::Parse, perl.
+
+AUTHOR
+ Casey West, <casey at geeknest.com>.
+
+COPYRIGHT
+ Copyright (c) 2004 Casey West. All rights reserved.
+ This module is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
Added: packages/libemail-date-perl/branches/upstream/current/lib/Email/Date.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-date-perl/branches/upstream/current/lib/Email/Date.pm?rev=3444&op=file
==============================================================================
--- packages/libemail-date-perl/branches/upstream/current/lib/Email/Date.pm (added)
+++ packages/libemail-date-perl/branches/upstream/current/lib/Email/Date.pm Sat Aug 12 08:12:05 2006
@@ -1,0 +1,141 @@
+package Email::Date;
+# $Id: Date.pm,v 1.3 2004/09/24 00:00:48 cwest Exp $
+use strict;
+
+use vars qw[$VERSION @EXPORT];
+$VERSION = sprintf "%d.%02d", split m/\./, (qw$Revision: 1.3 $)[1];
+ at EXPORT = qw[find_date format_date];
+
+use base qw[Exporter];
+use Date::Parse;
+use Email::Simple;
+use Time::Piece;
+use Time::Local;
+
+=head1 NAME
+
+Email::Date - Find and Format Date Headers
+
+=head1 SYNOPSIS
+
+ use Email::Date;
+
+ my $email = join '', <>;
+ my $date = find_date($email);
+ print $date->ymd;
+
+ my $header = format_date($date->epoch);
+
+ Email::Simple->create(
+ header => [
+ Date => $header,
+ ],
+ body => '...',
+ );
+
+=head1 DESCRIPTION
+
+RFC 2822 defines the C<Date:> header. It declares the header a required
+part of an email message. The syntax for date headers is clearly laid
+out. Stil, even a perfectly planned world has storms. The truth is, many
+programs get it wrong. Very wrong. Or, they don't include a C<Date:> header
+at all. This often forces you to look elsewhere for the date, and hoping
+to find something.
+
+For this reason, the tedious process of looking for a valid date has been
+encapsulated in this software. Further, the process of creating RFC
+compliant date strings is also found in this software.
+
+=head2 Functions
+
+=over 4
+
+=item find_date
+
+ my $time_piece = find_date $email;
+
+C<find_date> accepts an email message in any format
+L<Email::Abstract|Email::Abstract> can understand. It looks through the
+email message and finds a date, converting it to a
+L<Time::Piece|Time::Piece> object.
+
+=cut
+
+sub find_date {
+ my ($email) = _get_simple_object($_[0]);
+ my $date = $email->header('Date')
+ || _find_date_received($email->header('Recieved'))
+ || $email->header('Resent-Date');
+ Time::Piece->new(str2time $date);
+}
+
+sub _get_simple_object {
+ my ($email) = @_;
+ return $email if UNIVERSAL::isa($email, 'Email::Simple');
+ return Email::Simple->new($email) if ! ref($email);
+ require Email::Abstract;
+ return Email::Abstract->cast($email, 'Email::Simple');
+}
+
+sub _find_date_received {
+ return unless @_;
+ my $date = pop;
+ $date =~ s/.+;//;
+ $date;
+}
+
+=item format_date
+
+ my $date = format_date; # now
+ my $date = format_date( time - 60*60 ); # one hour ago
+
+C<format_date> accepts an epoch value, such as the one returned by C<time>.
+It returns a string representing the date and time of the input, as
+specified in RFC 2822. If no input value is provided, the current value
+of C<time> is used.
+
+=cut
+
+sub format_date {
+ my $time = shift || time;
+ my ($sec, $min, $hour, $mday, $mon, $year, $wday) = (localtime $time)[0..6];
+ my $day = (qw[Sun Mon Tue Wed Thu Fri Sat])[$wday];
+ my $month = (qw[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec])[$mon];
+ $year += 1900;
+
+ my $diff = Time::Local::timegm(localtime $time)
+ - Time::Local::timegm(gmtime $time);
+ my $direc = $diff < 0 ? '-' : '+';
+ $diff = abs $diff;
+ my $tz_hr = int( $diff / 3600 );
+ my $tz_mi = int( $diff / 60 - $tz_hr * 60 );
+
+ sprintf "%s, %d %s %d %02d:%02d:%02d %s%02d%02d",
+ $day, $mday, $month, $year, $hour, $min, $sec, $direc, $tz_hr, $tz_mi;
+
+}
+
+1;
+
+__END__
+
+=back
+
+=head1 SEE ALSO
+
+L<Email::Abstract>,
+L<Time::Piece>,
+L<Date::Parse>,
+L<perl>.
+
+=head1 AUTHOR
+
+Casey West, <F<casey at geeknest.com>>.
+
+=head1 COPYRIGHT
+
+ Copyright (c) 2004 Casey West. All rights reserved.
+ This module is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
+=cut
Added: packages/libemail-date-perl/branches/upstream/current/t/test.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-date-perl/branches/upstream/current/t/test.t?rev=3444&op=file
==============================================================================
--- packages/libemail-date-perl/branches/upstream/current/t/test.t (added)
+++ packages/libemail-date-perl/branches/upstream/current/t/test.t Sat Aug 12 08:12:05 2006
@@ -1,0 +1,14 @@
+use Test::More qw[no_plan];
+use strict;
+$^W = 1;
+
+BEGIN { use_ok 'Email::Date' }
+
+use Date::Parse;
+my @date = strptime(format_date);
+cmp_ok $date[-2], '>', 100, 'format_date returned something parsable';
+my $date = find_date(<<__MESSAGE__);
+Resent-Date: Tue, 6 Jul 2004 16:11:06 -0400
+__MESSAGE__
+
+isa_ok $date, 'Time::Piece';
More information about the Pkg-perl-cvs-commits
mailing list