HTML::...rftime(3pm)

πŸ“¦
version 2.07000 Β· 5 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– HTML::FormFu::Deflator::Strftime πŸ’–

okay bestie so this is HTML::FormFu::Deflator::Strftime, a page straight outta the User Contributed Perl Documentation, and it's a Strftime deflator. that's the whole vibe. let's get into it πŸ’…


✨ VERSION ✨

version 2.07 β€” that's the one, no cap 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole thing in action, literally copy-paste energy:

    $form->deflator( Strftime => 'start_time' )
        ->strftime( '%d/%m/%Y' );

    ---
    elements:
        - type: Text
          inflators:
              - type: DateTime
                parser:
                    strptime: "%Y/%m/%d"
          deflator:
              - type: Strftime
                strftime: "%Y/%m/%d"

see how it goes both ways?? strptime going in, strftime coming back out. it's giving symmetry. πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

so basically: this is a Strftime deflator for DateTime objects. πŸ•°οΈ

here's the situation. when you redisplay a form to the user after an invalid submission, any fields with DateTime inflators will stringify to something like '1970-01-01T00:00:00'. like… bestie. that is not the serve. 😭

in most cases it makes way more sense to use the same format you've asked the user for. that's the whole point of this deflator β€” it lets you specify a more suitable and user-friendly format. iconic behavior honestly ✨

ngl the mechanics are simple: this deflator calls DateTime's strftime method. the possible values for the format string are documented at:

<http://search.cpan.org/dist/DateTime/lib/DateTime.pm#strftime_Patterns>

(go read that if you wanna know your % codes, iykyk πŸ“–)

and here's a lil bonus moment πŸ’– β€” if you set the form's locale (see "locale" in HTML::FormFu), this gets set on the DateTime object. now you can use %x to get the default date, or %X for the default time, for the object's locale. localized date formatting?? we love to see it πŸ¦‹


πŸ‘‘ AUTHOR πŸ‘‘

Carl Franks, "cfranks@cpan.org" β€” the legend himself 🫢


πŸ’œ LICENSE πŸ’œ

this library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. slay, free software πŸ’…


🌸 AUTHOR 🌸

wait, again?? yes bestie, the manpage really does list it twice:

Carl Franks <cpan@fireartist.com> 🌈


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. periodt. πŸ’…


lowkey reminder: this whole thing rides on perl v5.28.1, dated 2019-01-12, and it lives in the User Contributed Perl Documentation. mwah, thanks for coming to my ted talk πŸŽ€πŸ’–βœ¨
πŸ“¦ where this page comes from