Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Handle multiple input date formats?
I have a date input field and I want to be able to handle 3/22/04,
22-mar-04, March 22, 2004, etc. I looked through the Module List and
there are dozens of Date/Time routines but no way to figure out which,
if any, will do what I want.

Clues for me please?

Report this thread to moderator Post Follow-up to this message
Old Post
fishfry
09-13-04 01:56 PM


Re: Handle multiple input date formats?
fishfry wrote:
> I have a date input field and I want to be able to handle 3/22/04,
> 22-mar-04, March 22, 2004, etc. I looked through the Module List
> and there are dozens of Date/Time routines but no way to figure out
> which, if any, will do what I want.

No way? Of course there is. One way is to browse the descriptions at
http://search.cpan.org/.

> Clues for me please?

http://search.cpan.org/perldoc?Date%3A%3AParse

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
09-13-04 01:56 PM


Re: Handle multiple input date formats?
fishfry wrote:
> I have a date input field and I want to be able to handle 3/22/04,
> 22-mar-04, March 22, 2004, etc. I looked through the Module List
> and there are dozens of Date/Time routines but no way to figure out
> which, if any, will do what I want.

No way? Of course there is. One way is to browse the descriptions at
http://search.cpan.org/.

> Clues for me please?

http://search.cpan.org/perldoc?Date%3A%3AParse

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
09-15-04 08:56 PM


Re: Handle multiple input date formats?
fishfry wrote:
> I have a date input field and I want to be able to handle 3/22/04,

Would this be the 22 of April in the year 2003 or the 22 of March in year
2004?

And you are lucky that there are no 22 months in the year. If you would have
used e.g. 05 instead in your example, then this would be 3rd of May 2004 in
most parts of the world.
And of course this doesn't even begin to address the complexity of any but
the Gregorian calender, e.g. the Hebrew calender, the Islamic calender, the
Japanese imperial calender, etc, etc. are left out.

If you allow a free form text field for date entry then the values you
receive will be useless.

> 22-mar-04, March 22, 2004, etc. I looked through the Module List and
> there are dozens of Date/Time routines but no way to figure out which,
> if any, will do what I want.
>
> Clues for me please?

Familiarize yourself with date formats that people actually use and you will
notice that an automatic "detection" ends up being an automated guess.

_YOU_ must define and enforce the format or people will enter dates in any
of dozens of ambiguous formats where no software or human can make a safe
call. You could just as well use a rand(), that's easier to do.

jue




Report this thread to moderator Post Follow-up to this message
Old Post
Jürgen Exner
09-16-04 02:22 AM


Re: Handle multiple input date formats?
In article <BLOCKSPAMfishfry-EFAC67.03554711092004@netnews.comcast.net>,
fishfry  <BLOCKSPAMfishfry@your-mailbox.com> wrote:
> I have a date input field and I want to be able to handle 3/22/04,
>22-mar-04, March 22, 2004, etc. I looked through the Module List and
>there are dozens of Date/Time routines but no way to figure out which,
>if any, will do what I want.
>

I agree with suggestions to enforce the format but you
may find Date::Manip useful for dealing with potential
variability.

For instance, if you specify "month day year", Date::Manip
handles several variants:

# perl -MDate::Manip -le 'print &ParseDate("3/22/04")'
2004032200:00:00

# perl -MDate::Manip -le 'print &ParseDate("March 22, 2004")'
2004032200:00:00

# perl -MDate::Manip -le 'print &ParseDate("mar-22-04")'
2004032200:00:00

perl -MDate::Manip -le 'print &ParseDate("03.22.04")'
2004032200:00:00

--
Charles DeRykus



Report this thread to moderator Post Follow-up to this message
Old Post
Charles DeRykus
09-16-04 09:52 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Modules archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:13 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.