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

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



Eric Albert wrote:
> 
> At 1:07 AM -0500 3/29/1999, Ronald J. Kimball wrote:
> >Eric Albert wrote:
> >>
> >> 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).
> >
> >Your example string is not consistent with that format...
> >
> > 4:21:00:000PM
> >hh:mm:sssPM
> >
> >I'll assume it's a typo in the example string.
> 
> Laziness again - I didn't write out the complete regex because most
> displays of date/time formats can generally be assumed to handle such
> things properly.  I'd expect \d\d? for hours....

No, I meant the example string has an extra colon and two extra digits.
(Or the format is missing a colon and two digits.)
The hour with space padding is obvious.  :)


> >For a more general solution, you might be interested in the Date::Parse
> >module.
> 
> Yep.  That seems to be exactly what I'd like, minus its inability to handle
> milliseconds starting with ':' instead of '.'.  That's easily fixed by
> changing (?:\.\d+)? to (?:[\.:]\d+)? on line 157, though.  Ah, the joy of
> open source.... :)
> 
> Thanks for the suggestion,
> Eric
> 

You're welcome!


Ronald

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