[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-AnyPerl] Dates, times, and month names



I *know* this is an FAQ.  I'm sure of it.  I just can't find the answer
that I'm looking for in a rather exhaustive DejaNews search, or via perldoc
-q, etc., and I'm certain that somebody here knows the answer.  I also know
that this has zilch to do with the Mac, but, well, it has a better chance
of being read here than in comp.lang.perl.*, and people here are probably
friendlier about stupid questions. :)

Anyway, I'm stuck with a Sybase database here (blech!).  Sybase's datetime
data type is returned from database calls as a string formatted like this:
'Apr 26 1999  4:21:00:000PM'  It's always in that format -- "mon dd yyyy
hh:mm:sssPM" (or AM) if you read the field directly (yes, you can use
concatenated converts...not pretty, and I'm looking for a Perl solution so
I can abstract it better).

Now, I'm looking to convert this to a formatted string like that of
strftime, probably using Time::CTime, that looks like this "April 26, 1999
4:21 PM".  That's trivial, except in the conversion from 'Apr' to 'April'.
If I don't want to hardcode my months into a hash -- it'd be nice to avoid
it, just for reasons of laziness and curiousity -- is there any way to do
the translation?  It seems that timelocal and related functions all require
month *numbers*; does anything allow a name?

Just wondering,
Eric

--
Eric Albert                     ejalbert@cs.stanford.edu
http://www.stanford.edu/~ejalbert/

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org