Permalink
Browse files

Implement Data.Period.overlaps

A new function for determining whether or not two periods overlap one
another.
  • Loading branch information...
1 parent 8493ce4 commit 388cb4b55a5d6f5f94cf0d68ec28d36614a2ee36 @mndrix committed Jul 23, 2010
Showing with 4 additions and 0 deletions.
  1. +4 −0 Data/Period.hs
View
@@ -24,6 +24,10 @@ instance Show Period where
within :: Period -> UTCTime -> Bool
within p t = ( start p <= t ) && ( t <= end p )
+-- Returns true if the two periods overlap each other
+overlaps :: Period -> Period -> Bool
+overlaps a b = ( end a >= start b ) && ( start a <= end b )
+
parsePeriod :: String -> IO Period
parsePeriod "today" = calendarPeriod 0 day
parsePeriod "yesterday" = calendarPeriod (-1) day

0 comments on commit 388cb4b

Please sign in to comment.