in reply to Re^3: Is there an easy way to get the start date of the current week?
in thread Is there an easy way to get the start date of the current week?

Not to be arguing, but what /would/ it be called then, when using the script in a multi-langual environment, or when you do not know what the locale will be at execution time?

I really like the simplicity of the approach. I always want to answer the stupid question "How do I print yesterday in perl?" with 'print "yesterday"', which is a perfect answer, but obviously not what the question was about. I've hit this locale problem way too often to not care, and if you'd use a regex match, the easy way out is to use { local $ENV{LC_TIME} = "en_US"; ... }.


Enjoy, Have FUN! H.Merijn
  • Comment on Re^4: Is there an easy way to get the start date of the current week?
  • Download Code

Replies are listed 'Best First'.
Re^5: Is there an easy way to get the start date of the current week?
by BrowserUk (Patriarch) on Aug 22, 2010 at 07:35 UTC

    How about:

    sub firstDayOfWeek { my $now = time; my @now = localtime $now; return $now - ( $now[ 6 ] * 2 - 1 ) * 43200; }

      :)


      Enjoy, Have FUN! H.Merijn

      For some people first day of week is Monday.

        And it's Saturday for others.

        But there is no way to automate for this arbitrary decision. Different companies in the same country, and even different departments within the same company can choose different definitions.