Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: d-mmm-yyyy to DOY (day of year)

by Kenosis (Priest)
on May 13, 2013 at 21:46 UTC ( #1033365=note: print w/ replies, xml ) Need Help??


in reply to d-mmm-yyyy to DOY (day of year)

Another use of POSIX::strptime:

use strict; use warnings; use POSIX::strptime; while (<DATA>) { my ($date) = /^([^,]+)/; my $doy = ( POSIX::strptime( $date, '%d-%b-%C' ) )[-1] + 1; print "Date: $date; DOY: $doy\n"; } __DATA__ 1-Apr-2012,615265,2.4,0,0,0,0,0,0,0,0,0,0,0.00,0.00,0.00,0.00,0.00 2-Apr-2012,615265,2.4,0,0,0,0,0,0,0,0,0,0,0.00,0.00,0.00,0.00,0.00 3-Apr-2012,615265,2.4,0,0,0,0,0,0,0,0,0,0,11.60,11.60,11.60,11.60,11.6 +0

Output:

Date: 1-Apr-2012; DOY: 92 Date: 2-Apr-2012; DOY: 93 Date: 3-Apr-2012; DOY: 94

Hope this helps!


Comment on Re: d-mmm-yyyy to DOY (day of year)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2015-07-03 11:27 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 (51 votes), past polls