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 find_date
38 my $time_piece = find_date $email;
39
40 "find_date" accepts an email message in any format Email::Abstract
41 can understand. It looks through the email message and finds a
42 date, converting it to a Time::Piece object.
43
44 If it can't find a date, it returns false.
45
46 "find_date" is exported by default.
47
48 format_date
49 my $date = format_date; # now
50 my $date = format_date( time - 60*60 ); # one hour ago
51
52 "format_date" accepts an epoch value, such as the one returned by
53 "time". It returns a string representing the date and time of the
54 input, as specified in RFC 2822. If no input value is provided, the
55 current value of "time" is used.
56
57 "format_date" is exported by default.
58
59 format_gmdate
60 my $date = format_gmdate;
61
62 "format_gmdate" is identical to "format_date", but it will return a
63 string indicating the time in Greenwich Mean Time, rather than
64 local time.
65
66 "format_gmdate" is exported on demand, but not by default.
67
69 This module is maintained by the Perl Email Project
70
71 <http://emailproject.perl.org/wiki/Email::Date>
72
74 Email::Abstract, Time::Piece, Date::Parse, perl.
75
77 Casey West, <casey@geeknest.com>.
78
79 Ricardo SIGNES, <rjbs@cpan.org>.
80
82 Copyright (c) 2004 Casey West. All rights reserved.
83 This module is free software; you can redistribute it and/or modify it
84 under the same terms as Perl itself.
85
86
87
88perl v5.12.0 2007-12-01 Email::Date(3)