
DateTime::Format::Builder::Parser::Regex - Regex based date parsing

version 0.81

my $parser = DateTime::Format::Builder->create_parser(
regex => qr/^(\d\d\d\d)(\d\d)(\d\d)T(\d\d)(\d\d)(\d\d)$/,
params => [ qw( year month day hour minute second ) ],
);

In addition to the common keys, Regex supports:
$1 to the first element, $2 to the second, and so on) and handed to DateTime->new(). This is a required element.DateTime->new(). For example, you could set the year or time_zone to defaults:
extra => { year => 2004, time_zone => "Australia/Sydney" },
$p and anything given in the extra option above.
If only a coderef is supplied, then it is called with arguments of $self, $p and extra.
In short:
$self->$coderef( %$p, %{ $self->{extra} } );
The method is expected to return a valid DateTime object, or undef in event of failure, but can conceivably return anything it likes. So long as it's 'true'.

See DateTime::Format::Builder for details.

datetime@perl.org mailing list.
perl, DateTime, DateTime::Format::Builder


This software is Copyright (c) 2013 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)