in reply to Check current time between range of dates and times

I would check out the Date::Calc module from CPAN

Date::Calc

I don't know if it has a function that does exactly what you are trying to do, but it, or one of its sibling modules will get you close...

addendum: This is available from ActiveState as well if that is your flavor...

  • ...the majority is always wrong, and always the last to know about it...
  • The Spice must flow...
  • ..by my will, and by will alone.. I set my mind in motion
  • Comment on Re: Check current time between range of dates and times

Replies are listed 'Best First'.
Re^2: Check current time between range of dates and times
by AcidHawk (Vicar) on May 13, 2009 at 15:16 UTC
    Yeah, thanks wjw I have looked (and still am looking) at Date::Calc and Date::Manip. However the logic is what I need more assistance on as apposed to what modules I need to use.

    Thanks though.

    -----
    Of all the things I've lost in my life, its my mind I miss the most.
      Sorry for the mis-understanding..., but this is an interesting problem to me.

      If you were to determine:

      • What week I am in
      • The epoch start and epoch end value of the week
      • The epoch start and epoch end of each blackout period within the current week

      perhaps place the epoch start ends in a HOL, then iterate through checking your that your current time is not between any of the start/end times in the hash.

      If I understand it right, you only want to check your current time against those in you xml file that have start and end times. The idea here is to collect all of them in one place in epoch format, check against each pair, and if now is not between any of them, do some action.

      But then I may be way off track here too.. .

      Thanks for posting the problem. It is related to some things I do every day with event based data, and it is good to try to see into a similar problem from a different perspective..

      • ...the majority is always wrong, and always the last to know about it...
      • The Spice must flow...
      • ..by my will, and by will alone.. I set my mind in motion