Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Check if Date interval contains Hour X

by alexm (Chaplain)
on Jul 23, 2009 at 18:42 UTC ( [id://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 (Patriarch) 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.

      Thanks!

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://782750]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-18 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found