in reply to Inscrutable test failure

You appear to be using Date::Manip ... correct?
  1. what time zone are all of these boxes running on?
    ParseDate assumes the TZ found in the environment when parsing, so "last sunday" in localtime can conceivable be noon the previous saturday (or thefollowing monday) in GMT. on top combine that you take the seconds since epoch returned by UnixDate and you then pass it to localtime ... which is only going to compound your problem.
  2. If you are going to use Date::Manip, why not use the Date_IsWorkDay function in conjuntion with teh configurable WorkWeekBeg, and WorkWeekEnd settings?

In general: make the message of your test give you more data (like exactly what 'time' (fully formated with an explicit timezone) you are passing to your function.

Replies are listed 'Best First'.
Re^2: Inscrutable test failure
by dsheroh (Monsignor) on Oct 26, 2007 at 21:21 UTC
    Correct. When I needed to get the epoch time value of "some random sunday" for testing, Date::Manip was the first thing that came to mind.

    1) My system is central US time, the test box I installed to is PHT (Phillipines), and I'm not sure whether the one it's failing on is using PHT or German time. Fun, no? But you're right - I had been assuming all operations would be in the machine's local time, regardless of what that may be. Is there a more reliable way to say "give me a time value for a day that is a Sunday/Tuesday in the current time zone"?

    2) The provided UI mockup included 7 checkboxes to indicate weekday/weekend status independently for each day, implying that the sets need not be contiguous. Su,Tu,Sa = weekend / M,W,Th,F = weekday doesn't work with a begin/end range.

      I think you want to use Date_DayOfWeek then, so something like Date_DayOfWeek(UnixDate(ParseDate('last saturday'),'%m', '%d','%y'))


      ___________
      Eric Hodges
        What would be the advantage of using that rather than (localtime ($date))[6]? The only differences I see, based on the Date::Manip docs, seem to be whether the date is specified in epoch seconds or as m/d/y and whether Sunday is considered to be day 0 or day 7.

        If there is an advantage, I can definitely switch, but I personally prefer to handle dates internally as epoch times and, in this case, to use localtime to get the day of week directly from that value rather than converting the epoch time to m/d/y so that m/d/y can be given to Date_DayOfWeek. I suppose I don't want to change it without knowing why I'm changing it.