Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: How to find first day of the first week on the month?

by BillKSmith (Chaplain)
on Sep 29, 2013 at 00:10 UTC ( #1056173=note: print w/ replies, xml ) Need Help??


in reply to Re: How to find first day of the first week on the month?
in thread How to find first day of the first week on the month?

It sure is an odd question. I thought he meant "What is the date of the first Sunday (or perhaps Monday) of the month?"

Bill


Comment on Re^2: How to find first day of the first week on the month?
Re^3: How to find first day of the first week on the month?
by kcott (Abbot) on Sep 29, 2013 at 07:01 UTC

    You could be right. We'll have to wait for devbond to tell us. Anyway, that's just as easy to calculate:

    #!/usr/bin/env perl -l use strict; use warnings; use Time::Piece; my $month = 10; my $year = 2013; for (1 .. 7) { # Time::Piece->wday returns: Sunday = 1, ..., Saturday += 7 print +($_ - Time::Piece->strptime("$year$month" . '01', '%Y%m%d') +->wday) % 7 + 1; }

    Output:

    6 7 1 2 3 4 5

    Check:

    $ cal 10 2013 October 2013 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

    -- Ken

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (14)
As of 2014-09-30 18:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (381 votes), past polls