HTML::...teTime(3pm)
π HTML::FormFu::Inflator::DateTime β the DateTime inflator, bestie π
okay so picture this: you're out here with a form, somebody types a date, and you need that little string of text to become a whole DateTime object. That's literally this module. It's HTML::FormFu::Inflator::DateTime, and it's giving glow-up-for-strings energy. β¨
VERSION: version 2.07 πΈ
β¨ SYNOPSIS β¨
---
elements:
- type: Text
name: start_date
inflators:
- type: DateTime
parser:
strptime: '%d-%m-%Y'
strptime:
pattern: '%d-%b-%Y'
locale: de
- type: Text
name: end_time
inflators:
- type: DateTime
time_zone: Europe/Rome
parser:
regex: '^ (\d{2}) - (\d{2}) - (\d{4}) $'
params: [day, month, year]
strptime: '%d-%m-%Y'
and then, a little serve: using the same parser declaration for both a DateTime constraint AND a DateTime inflator, via YAML references (yes, the & and * besties, we love a shared reference) π«Ά
---
elements:
- type: Text
name: date
constraints:
- type: DateTime
parser: &PARSER
strptime: '%d-%m-%Y'
inflators:
- type: DateTime
parser: *PARSER
π DESCRIPTION π
It inflates dates into DateTime objects. That's the whole job, and it does it flawlessly. π
If you're looking for the opposite direction β turning a DateTime back into a string β go see HTML::FormFu::Deflator::Strftime. They're basically the duo, the main characters, the pair. π
π METHODS π
π parser
Arguments: \%args
Required, no skips. You gotta define what the incoming string is supposed to look like, so that DateTime::Format::Builder knows how to inflate it into a DateTime object. π¦
It accepts arguments to be passed to "parser" in DateTime::Format::Builder.
π strptime
Arguments: \%args
Arguments: $string
Optional, babe. Define the format that should be used if the DateTime object is stringified. β¨
π time_zone
Arguments: $string
Optional. You can pass along a time_zone and that's the zone your DateTime will be created in. This is so useful when the string you're parsing doesn't carry time zone info and you want your DateTime sitting in a specific zone instead of the floating one (which, lowkey, is probably what you'd get otherwise). π
It accepts a hashref of arguments to be passed to "new" in DateTime::Format::Strptime. OR β alternate route, pick your fighter β it accepts a single string argument, suitable for passing to "DateTime::Format::Strptime->new( pattern => $string )".
π AUTHOR π
Carl Franks, "cfranks@cpan.org"
π LICENSE π
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. fr fr.
π AUTHOR π (yes, again, iconic)
Carl Franks <cpan@fireartist.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2018 by Carl Franks.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay that's the whole thing, you ate it, periodt π β¨
signing off from the User Contributed Perl Documentation corner, where perl v5.28.1 said hey on 2019-01-12 π
π¦ where this page comes from
- debian bookworm: libhtml-formfu-perl 2.07000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libhtml-formfu-perl 2.07000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-formfu-perl 2.07000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms