1Email::Date(3) User Contributed Perl Documentation Email::Date(3)
2
3
4
6 Email::Date - Find and Format Date Headers
7
9 use Email::Date;
10
11 my $email = join '', <>;
12 my $date = find_date($email);
13 print $date->ymd;
14
15 my $header = format_date($date->epoch);
16
17 Email::Simple->create(
18 header => [
19 Date => $header,
20 ],
21 body => '...',
22 );
23
25 RFC 2822 defines the "Date:" header. It declares the header a required
26 part of an email message. The syntax for date headers is clearly laid
27 out. Stil, even a perfectly planned world has storms. The truth is,
28 many programs get it wrong. Very wrong. Or, they don't include a
29 "Date:" header at all. This often forces you to look elsewhere for the
30 date, and hoping to find something.
31
32 For this reason, the tedious process of looking for a valid date has
33 been encapsulated in this software. Further, the process of creating
34 RFC compliant date strings is also found in this software.
35
36 FUNCTIONS
37
38 find_date
39 my $time_piece = find_date $email;
40
41 "find_date" accepts an email message in any format Email::Abstract
42 can understand. It looks through the email message and finds a
43 date, converting it to a Time::Piece object.
44
45 If it can't find a date, it returns false.
46
47 "find_date" is exported by default.
48
49 format_date
50 my $date = format_date; # now
51 my $date = format_date( time - 60*60 ); # one hour ago
52
53 "format_date" accepts an epoch value, such as the one returned by
54 "time". It returns a string representing the date and time of the
55 input, as specified in RFC 2822. If no input value is provided, the
56 current value of "time" is used.
57
58 "format_date" is exported by default.
59
60 format_gmdate
61 my $date = format_gmdate;
62
63 "format_gmdate" is identical to "format_date", but it will return a
64 string indicating the time in Greenwich Mean Time, rather than
65 local time.
66
67 "format_gmdate" is exported on demand, but not by default.
68
70 This module is maintained by the Perl Email Project
71
72 <http://emailproject.perl.org/wiki/Email::Date>
73
75 Email::Abstract, Time::Piece, Date::Parse, perl.
76
78 Casey West, <casey@geeknest.com>.
79
80 Ricardo SIGNES, <rjbs@cpan.org>.
81
83 Copyright (c) 2004 Casey West. All rights reserved.
84 This module is free software; you can redistribute it and/or modify it
85 under the same terms as Perl itself.
86
87
88
89perl v5.8.8 2007-03-22 Email::Date(3)