Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Coolest way to decode YYYYMMDD?

by erix (Vicar)
on Jun 03, 2013 at 06:53 UTC ( #1036677=note: print w/ replies, xml ) Need Help??


in reply to Coolest way to decode YYYYMMDD?

Why all the contortions? Keep it simple and talk to your database:

$ echo "select to_char(to_date('19830501?','YYYYMMDD'), 'FMMon FMdd, y +yyy?')" \ | perl -MDBI -ne ' print DBI->connect("dbi:Pg:")->selectall_arrayref($_)->[0]->[0], + "\n"; '; May 1, 1983?

;-)

P.S. (Looks I am the first one to spot the terminal question mark in your example? Does that get me Mega-XP too?)


Comment on Re: Coolest way to decode YYYYMMDD?
Download Code
Re^2: Coolest way to decode YYYYMMDD?
by Your Mother (Chancellor) on Jun 03, 2013 at 13:48 UTC

    The question mark is ambiguous in this context but it's proper English style see below. Liked your direct approach. :P

      it's proper English style.

      Actually... No, it's not. While there is some (little) conflict over when/whether periods & commas should go inside, all authorities agree that "question marks and exclamation points follow [i.e. go outside] closing quotation marks unless they belong within the quoted matter." (Chicago Manual)

      I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.

        While I will take issue with Chicago being il capo di tutti authorities, I will take the correction to season the crow of my mistakenly conflating commas and periods with question marks and bangs.

Re^2: Coolest way to decode YYYYMMDD?
by hdb (Prior) on Jun 03, 2013 at 16:56 UTC

    If DateTime is not a requirement, and short month names are ok (difficult to say with "May" as the only example), then I offer this:

    printf('"%s %d,%d?"',substr(gmtime(34e6*('19830501'=~/(....)(..)(..)/) +[1]),4,3),$3,$1);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036677]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (13)
As of 2015-07-06 22:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls