-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Thanks for all the replies.

I'm tesing the Text::ParseWords

I'm new in Perl and I'm a little bit confused with the PATTERNS
option but I'm learning it.

Is this code good for checking valid date in the format YYYY-MM-DD?
or do you have any other suggestions

sub isvaliddate {
~  my $input = shift;
~  if ($input =~ m!^((?:19|20)\d\d)[- /.](0[1-9]|1[012])[-
/.](0[1-9]|[12][0-9]|3[01])$!) {
~    # At this point, $1 holds the year, $2 the month and $3 the day
of the date entered
~    if ($3 == 31 and ($2 == 4 or $2 == 6 or $2 == 9 or $2 == 11)) {
~      return 0; # 31st of a month with 30 days
~    } elsif ($3 >= 30 and $2 == 2) {
~      return 0; # February 30th or 31st
~    } elsif ($2 == 2 and $3 == 29 and not ($1 % 4 == 0 and ($1 % 100
<> 0 or $1 % 400 == 0))) {
~      return 0; # February 29th outside a leap year
~    } else {
~      return 1; # Valid date
~    }
~  } else {
~    return 0; # Not a date
~  }
}

The link for that code is
http://www.regular-expressions.info/dates.html coz you might not
understand the code

Thanks,

Michael Louie Loria
-----BEGIN PGP SIGNATURE-----
Comment: Public Key: https://www.biglumber.com/x/web?qs=0x4A256EC8
Comment: Public Key: http://www.lorztech.com/GPG.txt
Comment: Yahoo ID: michaellouieloria

iQEVAwUBQua0F7XBHi2y3jwfAQoUaAf/dkEy1hqp6dG/tBONFj7EPU7/XP+YqBgL
YRXEo64R8CP3yMkUJXTQrKSEUWVeitgF2lim1BRzR1VfvTDLFJn1kh02n7tVgw1z
/F9n2y0O9pKbqkCm6BE7zzLiZpfPMS+weycbwUvp6dVUVjOLZ073b2LhAcvfq4UU
bTMqRLicxIPFTq9U1HPXCq3rrq3PK/u1CLSNfu/7GXoQ64eXSb+TrPdnNTgGLwEh
A9KtGrKgGrOkFyhA8dPNypR1aaRVszWTHTUSjRxivXlfjJOmtY1/iIEAN8pVLOUc
9z35ht6O4o3CIBGUOtDF34r8Y2MYTs9mFSJ/7lcBOYtnZN02dUYHSQ==
=3GPb
-----END PGP SIGNATURE-----

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to