Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Check if Date interval contains Hour X

by alexm (Chaplain)
on Jul 23, 2009 at 18:42 UTC ( #782750=note: print w/replies, xml ) Need Help??

in reply to Check if Date interval contains Hour X

I'd suggest taking a look into DateTime::Span.
  • Comment on Re: Check if Date interval contains Hour X

Replies are listed 'Best First'.
Re^2: Check if Date interval contains Hour X
by ikegami (Pope) on Jul 23, 2009 at 19:21 UTC
    I thought you were on to something until I realized the real problem is finding the right date to go with the hour. Using ::Span makes things a lot more complicated since you now need to make 4 DateTime objects for every hour.

      The very first thing that came to my mind after reading the OP was the method DateTime::Span::contains. However, yours is the right approach since that method only works for sets that are fully inside, as the manual says.


        contains wouldn't work, but intersects would
        ...| 20 | 21 | 22 | 23 | 00 | 01 | 02 | 03 |... (------------) log (----] hour (--) intersection

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://782750]
[james28909]: i figured out a neet trick
[Lady_Aleena]: james28909, what neat trick?
[james28909]: now if i have packed a script into a PDK exe, and misplaced the source, i can print it.
[james28909]: but you have to prepare for it first by adding this to the source
[james28909]: seek DATA, 0, 0; while (<DATA>) { print; }
[Lady_Aleena]: Sounds interesting. Have you written a meditation or cool use for it?
[Lady_Aleena]: It might be something PerlMonks at large would be interested in.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2017-05-01 00:06 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (543 votes). Check out past polls.