Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Gettting the last Friday of every month using Time::Piece

by toolic (Bishop)
on Jun 30, 2014 at 16:08 UTC ( [id://1091746]=note: print w/replies, xml ) Need Help??


in reply to Gettting the last Friday of every month using Time::Piece

use strict; use warnings; use Time::Piece; use Time::Seconds; my $t = Time::Piece->new(); my $year = $ARGV[ 0 ] || 2014; foreach my $month ( 1 .. 12 ) { my $tdates = $t->strptime("$year/$month/1", '%Y/%m/%d'); my $day_of_month = $tdates->month_last_day(); $tdates = $t->strptime("$year/$month/$day_of_month", '%Y/%m/%d'); while ($tdates->wdayname ne 'Fri') { $tdates -= ONE_DAY; } printf "Last Friday of Month %02d is %s\n", $month, $tdates->ymd() +; } __END__ Last Friday of Month 01 is 2014-01-31 Last Friday of Month 02 is 2014-02-28 Last Friday of Month 03 is 2014-03-28 Last Friday of Month 04 is 2014-04-25 Last Friday of Month 05 is 2014-05-30 Last Friday of Month 06 is 2014-06-27 Last Friday of Month 07 is 2014-07-25 Last Friday of Month 08 is 2014-08-29 Last Friday of Month 09 is 2014-09-26 Last Friday of Month 10 is 2014-10-31 Last Friday of Month 11 is 2014-11-28 Last Friday of Month 12 is 2014-12-26

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 16:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found