|1.||A strict parser that will only accept RFC2822 dates, so you can see where youre right.|
|2.||A strict formatter, so you can generate the right stuff to begin with.|
|3.||A loose parser, so you can take the misbegotten output from other programs and turn it into something useful. This includes various minor errors as well as some somewhat more bizarre mistakes. The file t/sample_dates in this modules distribution should give you an idea of whats valid, while t/invalid.t should do the same for whats not. Those regarded as invalid are just a bit <B>tooB> strange to allow.|
|4.||Interoperation with the rest of the DateTime suite. These are a collection of modules to handle dates in a modern and accurate fashion. In particular, they make it trivial to parse, manipulate and then format dates. Shifting timezones is a doddle, and converting between formats is a cinch.|
Creates a new DateTime::Format::Mail instance. This is generally not required for simple operations. If you wish to use a different parsing style from the default, strict, parser then youll need to create an object.
my $parser = DateTime::Format::Mail->new() my $copy = $parser->new();
If called on an existing object then it clones the object.
It has two optional named parameters.
o loose should be a true value if you want a loose parser, else either dont specify it or give it a false value. o year_cutoff should be an integer greater than or equal to zero specifying the cutoff year. See set_year_cutoff for details.
For those who prefer to explicitly clone via a method called clone(). If called as a class method it will die.
my $clone = $original->clone();
These methods work on either our objects or as class methods.
These methods set the parsing strictness.
Given an RFC2822 or 822 datetime string, return a DateTime object representing that date and time. Unparseable strings will cause the method to die.
See the synopsis for examples.
Two digit years are treated as valid in the loose translation and are translated up to a 19xx or 20xx figure. By default, following the specification of RFC2822, if the year is greater than 49, its treated as being in the 20th century (19xx). If lower, or equal, then the 21st (20xx). That is, 50 becomes 1950 while 49 is 2049.
set_year_cutoff() allows you to modify this behaviour by specifying a different cutoff.
The return value is the object itself.
$parser->set_year_cutoff( 60 );
Returns the current cutoff. Can be used as either a class or object method.
my $cutoff = $parser->set_year_cutoff;
Returns the default cutoff. A useful method to override for subclasses.
my $default = $parser->default_cutoff;
Takes a year and returns it normalized.
my $fixed = $parser->fix_year( 3 );
Given a DateTime object, return it as an RFC2822 compliant string.
use DateTime; use DateTime::Format::Mail; my $dt = DateTime->new( year => 1979, month => 7, day => 16, time_zone => UTC ); my $mail = DateTime::Format::Mail->format_datetime( $dt ); print $mail, "\n"; # or via an object my $formatter = DateTime::Format::Mail->new(); my $rfcdate = $formatter->format_datetime( $dt ); print $rfcdate, "\n";
Dave Rolsky (DROLSKY) for kickstarting the DateTime project.
Roderick A. Anderson for noting where the documentation was incomplete in places.
Joshua Hoblitt (JHOBLITT) for inspiring me to check what the standard said about interpreting two digit years.
Support for this module is provided via the email@example.com email list. See <http://datetime.perl.org/mailing_list.html> for more details.
Alternatively, log them via the CPAN RT system via the web or email:
This makes it much easier for me to track things and thus means your problem is less likely to be neglected.
Copyright X Iain Truskett, 2003. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Originally written by Iain Truskett <firstname.lastname@example.org>, who died on December 29, 2003.
Maintained by Dave Rolsky <email@example.com>.
firstname.lastname@example.org mailing list.
RFCs 2822 and 822.
|perl v5.20.3||DATETIME::FORMAT::MAIL (3)||2016-04-03|