Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by Kenosis (Priest)
on May 13, 2013 at 21:46 UTC ( [id://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!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-25 05:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found