in reply to date validation module
Date::Calc has a check_date function. From the docs:
This function returns ``true'' (``1'') if the given three numerical values ``$year'', ``$month'' and ``$day'' constitute a valid date, and ``false'' (``0'') otherwise.if (check_date($year,$month,$day))
For example:
This prints:use strict; use warnings; use Date::Calc qw( check_date ); my ( $year, $month, $day ) = ( 2006, 1, 30 ); printf "[$year, $month, $day] %s a valid date\n", check_date( $year, $month, $day ) ? 'is' : 'is not'; ( $year, $month, $day ) = ( 2006, 1, 32 ); printf "[$year, $month, $day] %s a valid date\n", check_date( $year, $month, $day ) ? 'is' : 'is not'; ( $year, $month, $day ) = ( 2006, 2, 29 ); printf "[$year, $month, $day] %s a valid date\n", check_date( $year, $month, $day ) ? 'is' : 'is not';
[2006, 1, 30] is a valid date [2006, 1, 32] is not a valid date [2006, 2, 29] is not a valid date
|
|---|