in reply to Re^2: 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?

In a locale where "Sun" is not Sunday

But then the routine would not be called lastSunday() either...

  • Comment on Re^3: Is there an easy way to get the start date of the current week?
  • Download Code

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

    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

      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.