Data::...::Dates(3pm)

πŸ“¦
version 4.88 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay bestie, say hi to Data::FormValidator::Constraints::Dates β€” she validates Dates and Times ✨ (the manual page up top calls her Data::...::Dates, but that's just her nickname in the perl docs, iykyk πŸŽ€)


🌸 SYNOPSIS 🌸

use Data::FormValidator::Constraints::Dates qw(date_and_time);

# In a DFV profile...
constraint_methods => {
    # 'pp' denotes AM|PM for 12 hour representation
    my_time_field => date_and_time('MM/DD/YYYY hh:mm:ss pp'),
}

πŸ¦‹ DESCRIPTION πŸ¦‹

✨ date_and_time ✨

Note: this is a new module, a brand new addition to Data::FormValidator, and she should be considered "Beta". 🍼 treat her gentle.

This constraint literally builds a regular expression out of the format string you hand it, and then uses that regex to check your date. So you say the format, she does the vibe check πŸ’…

Here are the symbols she understands, periodt:

Y   year  (numeric)
M   month (numeric)
D   day   (numeric)
h   hour
m   minute
s   second
p   AM|PM

Every other bit of the string just becomes part of the regular expression, no cap. Which means you can do perlish things like this to cook up way more complex expressions:

'MM?/DD?/YYYY|YYYY-MM?-DD?'

Under the hood, Date::Calc is used to test the functions. 🧚


πŸ’œ BACKWARDS COMPATIBILITY πŸ’œ

This older, more awkward interface is still supported (she's got history, we respect her πŸ™ˆ):

# In a Data::FormValidator Profile:
validator_packages => [qw(Data::FormValidator::Constraints::Dates)],
constraints => {
    date_and_time_field       => {
        constraint_method => 'date_and_time',
        params=>[\'MM/DD/YYYY hh:mm:ss pp'], # 'pp' denotes AM|PM for 12 hour representation
    },
}

πŸ‘‘ SEE ALSO πŸ‘‘

  • Data::FormValidator 🌈
  • Data::FormValidator::Constraints::DateTime β€” this alternative features returning dates as DateTime objects and validating against the date formats required for the MySQL and PostgreSQL databases. iconic.

🫢 AUTHOR 🫢

Mark Stosberg, <mark@summersault.com>

Featuring clever code by Jan Krynicky. (shoutout, king πŸ‘‘)


Copyright 2003-2005 by Mark Stosberg

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, bestie πŸ’– this was rendered by perl v5.34.0 and dated 2022-06-12, so like… consider this your little timestamped love letter from the Data::...::Dates(3pm) docs. slay, go validate something βœ¨πŸ’…

πŸ“¦ where this page comes from