1DateTime::Format::BuildUesre:r:PCaornsterri:b:uRtDeeagdteexPT(ei3rm)le:D:oFcourmmeantt:a:tBiuoinlder::Parser::Regex(3)
2
3
4
6 DateTime::Format::Builder::Parser::Regex - Regex based date parsing
7
9 version 0.81
10
12 my $parser = DateTime::Format::Builder->create_parser(
13 regex => qr/^(\d\d\d\d)(\d\d)(\d\d)T(\d\d)(\d\d)(\d\d)$/,
14 params => [ qw( year month day hour minute second ) ],
15 );
16
18 In addition to the common keys, "Regex" supports:
19
20 · regex is a regular expression that should capture elements of the
21 datetime string. This is a required element. This is the key whose
22 presence indicates it's a specification that belongs to this class.
23
24 · params is an arrayref of key names. The captures from the regex are
25 mapped to these ($1 to the first element, $2 to the second, and so
26 on) and handed to "DateTime->new()". This is a required element.
27
28 · extra is a hashref of extra arguments you wish to give to
29 "DateTime->new()". For example, you could set the "year" or
30 "time_zone" to defaults:
31
32 extra => { year => 2004, time_zone => "Australia/Sydney" },
33
34 · constructor is either an arrayref or a coderef. If an arrayref then
35 the first element is a class name or object, and the second element
36 is a method name (or coderef since Perl allows that sort of thing).
37 The arguments to the call are anything in $p and anything given in
38 the "extra" option above.
39
40 If only a coderef is supplied, then it is called with arguments of
41 $self, $p and "extra".
42
43 In short:
44
45 $self->$coderef( %$p, %{ $self->{extra} } );
46
47 The method is expected to return a valid DateTime object, or undef
48 in event of failure, but can conceivably return anything it likes.
49 So long as it's 'true'.
50
52 See DateTime::Format::Builder for details.
53
55 "datetime@perl.org" mailing list.
56
57 http://datetime.perl.org/
58
59 perl, DateTime, DateTime::Format::Builder
60
62 · Dave Rolsky <autarch@urth.org>
63
64 · Iain Truskett
65
67 This software is Copyright (c) 2013 by Dave Rolsky.
68
69 This is free software, licensed under:
70
71 The Artistic License 2.0 (GPL Compatible)
72
73
74
75perl v5.28.0 20D1a8t-e0T7i-m1e4::Format::Builder::Parser::Regex(3)