in reply to More date conversion happiness
Date::Manip is able to parse a wide variety of date formats automatically. There's half the assignment, already done.
I can't remember if Date::Manip is a core module or not. If not, you can download it from CPAN, or if you're an ActiveState user, just pull it in with PPM.
From the Date Manip POD:
In the documentation below, US formats are used, but in most (if not all) cases, a non-English equivalent will work equally well.1. Parsing a date from any convenient format
$date = ParseDate("today"); $date = ParseDate("1st thursday in June 1992"); $date = ParseDate("05/10/93"); $date = ParseDate("12:30 Dec 12th 1880"); $date = ParseDate("8:00pm december tenth"); if (! $date) { # Error in the date }
Even if you're not allowed to use the Date::Manip module, at least look at its source code so you can see how it does all those neat tricks!
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: More date conversion happiness
by ctp (Beadle) on Jan 09, 2004 at 08:43 UTC |