Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How to find week of the month?

by newroz (Monk)
on Aug 17, 2005 at 09:08 UTC ( #484347=note: print w/ replies, xml ) Need Help??


in reply to How to find week of the month?

perl -e 'use POSIX; my $date=strftime("%w",localtime); print $date;'
Directives(%w) are same as date command. look
"perldoc POSIX" and "info date"


Comment on Re: How to find week of the month?
Replies are listed 'Best First'.
Re^2: How to find week of the month?
by Joost (Canon) on Aug 17, 2005 at 09:34 UTC
    That gives the day of the week in range 0 .. 6 with sunday as day 0. Week of of the month isn't available in strftime().

    DateTime has a week_of_month method, which is defined as

    The first week of the month is the first week that contains a Thursday. This is based on the ICU definition of week of month, and correlates to the ISO8601 week of year definition. A day in the week before the week with the first Thursday will be week 0.

    But I can't guess if that's the definition the OP wants.

      Sorry for misunderstood.Yes, you're right.
      sprintf doesn't provide it.
      And there is one more module that provides week of month.
      Date::Handler

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2015-07-30 00:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls