# How do I find overlaps between two Ruby Runt patterns?

**URL:** <https://www.ruby-forum.com/t/how-do-i-find-overlaps-between-two-ruby-runt-patterns/170834>\
**Category:** Ruby\
**Created:** [June 23, 2009, 9:49am UTC](https://www.ruby-forum.com/t/how-do-i-find-overlaps-between-two-ruby-runt-patterns/170834 "2009-06-23T09:49:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@amit](https://www.ruby-forum.com/u/amit)\
**Post date:** [June 23, 2009, 9:49am UTC](https://www.ruby-forum.com/t/how-do-i-find-overlaps-between-two-ruby-runt-patterns/170834/1 "2009-06-23T09:49:51Z")

</div>

I am developing a Google like calendar on Rails and am using Runt to  
define the recurrence patterns for creating events. However, the  
restriction with the calendar is that there cannot be two events for  
same time slot. So, if i have an event created with

event = REDay.new(13,00,15,00) # daily between 1PM to 3 PM

Then the application should not allow to create another event that  
overlaps this one.

Is there some way of finding whether a Runt expression overlaps with  
another expression?

I came across similar question at

> <https://stackoverflow.com/questions/831864/finding-schedule-overlaps-with-ruby-runt>

and the solution says that “create a DateRange object from your expr and  
then run overlap”, but i am not sure how to do this. Also, what would  
happen where there is no date range e.g. in the example given above  
there is no start and end date.
