Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re: Gettting the last Friday of every month using Time::Piece by toolic
in thread Gettting the last Friday of every month using Time::Piece by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-23 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found