in reply to Numeric Date Validation
Date::Manip can do quite a lot, but not everything. Check this test script.
#!/usr/bin/perl -w use strict; use Date::Manip; while (<DATA>) { chomp; my $date = ParseDate($_); if ($date) { print "$_ \t=> ", UnixDate($date,"%b %e, %Y."),"\n"; } else { print "$_ \t=> not a valid date\n"; } } __DATA__ 19971103 11031997 11.03.1997 19983201 20031110 20031011 1993jan02 2002dec08 yesterday today tomorrow Aug12 12Aug2003 Aug122003 122003Aug
output: 19971103 => Nov 3, 1997. 11031997 => not a valid date 11.03.1997 => Nov 3, 1997. 19983201 => not a valid date 20031110 => Nov 10, 2003. 20031011 => Oct 11, 2003. 1993jan02 => Jan 2, 1993. 2002dec08 => Dec 8, 2002. yesterday => Sep 29, 2003. today => Sep 30, 2003. tomorrow => Oct 1, 2003. Aug12 => Aug 12, 2003. 12Aug2003 => Aug 12, 2003. Aug122003 => Aug 12, 2003. 122003Aug => Aug 12, 2003.
Your 11031997 is not recognized as it is, but it is parsed correctly if you add dots. Check the documentation to see which formats are recognized. You see from the example that it is quite flexible.
Be aware, though, that Date::Manip is very slow compared to direct regexp manipulation. Check the docs for this issue as well.
HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Numeric Date Validation
by jdtoronto (Prior) on Sep 30, 2003 at 19:20 UTC |