DateTim...::Regex(3)
π NAME π
ok so this is DateTime::Format::Builder::Parser::Regex β it's the regex-based date parsing parser, bestie. That's the whole vibe: you give it a regex, it gives you dates β¨
π VERSION π
version 0.83 β yes that's the number, write it down π«Ά
π¦ SYNOPSIS π¦
like, here's the moment you've been waiting for:
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 )],
);
no cap, that's it. that's the whole thing π
πΈ SPECIFICATION πΈ
so beyond the common keys (iykyk), Regex also supports these bad boys:
regexβ this is a regular expression that should capture elements of the datetime string. it's a required element, periodt. this is also the key whose presence is what tells everyone "hey, this spec belongs to this class" πparamsβ an arrayref of key names. the captures from the regex get mapped onto these ($1goes to the first element,$2to the second, and so on and so forth) and then handed off toDateTime->new. also required, no skipping πextraβ a hashref of extra arguments you wanna hand toDateTime->new. like, you could set theyearortime_zoneto defaults:
extra => { year => 2004, time_zone => "Australia/Sydney" },
iconic little defaults moment π
constructoris either an arrayref or a coderef. if it's an arrayref, then the first element is a class name or object, and the second element is a method name (or a coderef, since Perl literally allows that sort of thing π« ). the arguments to the call are anything in$pplus anything you gave in theextraoption up above.
if you only supply a coderef, then it gets called with arguments of $self, $p and extra.
in short, bestie:
$self->$coderef( %{$p}, %{ $self->{extra} } );
the method is expected to return a valid DateTime object, or undef if it fails π β but it can conceivably return anything it likes. so long as it's 'true', we're chilling β¨
π SEE ALSO π
- the
"datetime@perl.org"mailing list π§ - http://datetime.perl.org/
perl,DateTime,DateTime::Format::Builder
π§ SUPPORT π§
bugs may be submitted at <https://github.com/houseabsolute/DateTime-Format-Builder/issues> β go off, report that bug π
I'm also usually active on IRC as 'autarch' on "irc://irc.perl.org" π come say hi fr fr
β SOURCE β
the source code repository for DateTime-Format-Builder can be found at <https://github.com/houseabsolute/DateTime-Format-Builder> β go look, it's giving open source excellence π
π AUTHORS π
- Dave Rolsky <autarch@urth.org>
- Iain Truskett <spoon@cpan.org>
legends, both of them π«Ά
π COPYRIGHT AND LICENSE π
this software is Copyright (c) 2020 by Dave Rolsky.
this is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
the full text of the license can be found in the LICENSE file included with this distribution π read it, it's good for you π
okay that's the whole page, mwah π β sign-off time: this was perl v5.40.0, dated 2023-01-15, and yes it's still DateTime::Format::Builder::Parser::Regex(3) in case you forgot already ππ
π¦ where this page comes from
- epel 10: perl-DateTime-Format-Builder 0.8300-9.el10_0 Β· Artistic-2.0 AND (GPL-1.0-or-later OR Artistic-1.0-Perl)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms