=head1 NAME DateTime::Format::Builder - Create DateTime parser classes and objects. =head1 SYNOPSIS package DateTime::Format::Brief; our $VERSION = '0.07'; use DateTime::Format::Builder ( parsers => { parse_datetime => [ { regex => qr/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/, params => [qw( year month day hour minute second )], }, { regex => qr/^(\d{4})(\d\d)(\d\d)$/, params => [qw( year month day )], }, ], } ); =head1 DESCRIPTION DateTime::Format::Builder creates DateTime parsers. Many string formats of dates and times are simple and just require a basic regular expression to extract the relevant information. Builder provides a simple way to do this without writing reams of structural code. Builder provides a number of methods, most of which you'll never need, or at least rarely need. They're provided more for exposing of the module's innards to any subclasses, or for when you need to do something slightly beyond what I expected. =head1 TUTORIAL See L. =head1 ERROR HANDLING AND BAD PARSES Often, I will speak of C being returned, however that's not strictly true. When a simple single specification is given for a method, the method isn't given a single parser directly. It's given a wrapper that will call C if the single parser returns C. The single parser must return C so that a multiple parser can work nicely and actual errors can be thrown from any of the callbacks. Similarly, any multiple parsers will only call C right at the end when it's tried all it could. C (see L) is defined, by default, to throw an error. Multiple parser specifications can also specify C with a coderef as an argument in the options block. This will take precedence over the inheritable and over-ridable method. That said, don't throw real errors from callbacks in multiple parser specifications unless you really want parsing to stop right there and not try any other parsers. In summary: calling a B will result in either a C object being returned or an error being thrown (unless you've overridden C or C, or you've specified a C key to a multiple parser specification). Individual B (be they multiple parsers or single parsers) will return either the C object or C. =head1 SINGLE SPECIFICATIONS A single specification is a hash ref of instructions on how to create a parser. The precise set of keys and values varies according to parser type. There are some common ones though: =over 4 =item * B is an optional parameter that can be used to specify that this particular I is only applicable to strings of a certain fixed length. This can be used to make parsers more efficient. It's strongly recommended that any parser that can use this parameter does. You may happily specify the same length twice. The parsers will be tried in order of specification. You can also specify multiple lengths by giving it an arrayref of numbers rather than just a single scalar. If doing so, please keep the number of lengths to a minimum. If any specifications without Is are given and the particular I parser fails, then the non-I parsers are tried. This parameter is ignored unless the specification is part of a multiple parser specification. =item * B