Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 about the Monastery: (5)
As of 2014-10-25 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (141 votes), past polls