lib: clean up queryDateSpan, queryDateSpan' (api change)
These now intersect date AND'ed date spans, instead of unioning them, and docs are clearer.
This commit is contained in:
parent
2fbebc6c64
commit
91e5baf617
@ -530,33 +530,27 @@ queryEndDate _ _ = Nothing
|
|||||||
queryTermDateSpan (Date span) = Just span
|
queryTermDateSpan (Date span) = Just span
|
||||||
queryTermDateSpan _ = Nothing
|
queryTermDateSpan _ = Nothing
|
||||||
|
|
||||||
-- | What date span (or secondary date span) does this query specify ?
|
-- | What date span (or with a true argument, what secondary date span) does this query specify ?
|
||||||
-- For OR expressions, use the widest possible span. NOT is ignored.
|
-- OR clauses specifying multiple spans return their union (the span enclosing all of them).
|
||||||
|
-- AND clauses specifying multiple spans return their intersection.
|
||||||
|
-- NOT clauses are ignored.
|
||||||
queryDateSpan :: Bool -> Query -> DateSpan
|
queryDateSpan :: Bool -> Query -> DateSpan
|
||||||
queryDateSpan secondary q = spansUnion $ queryDateSpans secondary q
|
queryDateSpan secondary (Or qs) = spansUnion $ map (queryDateSpan secondary) qs
|
||||||
|
queryDateSpan secondary (And qs) = spansIntersect $ map (queryDateSpan secondary) qs
|
||||||
|
queryDateSpan False (Date span) = span
|
||||||
|
queryDateSpan True (Date2 span) = span
|
||||||
|
queryDateSpan _ _ = nulldatespan
|
||||||
|
|
||||||
-- | Extract all date (or secondary date) spans specified in this query.
|
-- | What date span does this query specify, treating primary and secondary dates as equivalent ?
|
||||||
-- NOT is ignored.
|
-- OR clauses specifying multiple spans return their union (the span enclosing all of them).
|
||||||
queryDateSpans :: Bool -> Query -> [DateSpan]
|
-- AND clauses specifying multiple spans return their intersection.
|
||||||
queryDateSpans secondary (Or qs) = concatMap (queryDateSpans secondary) qs
|
-- NOT clauses are ignored.
|
||||||
queryDateSpans secondary (And qs) = concatMap (queryDateSpans secondary) qs
|
|
||||||
queryDateSpans False (Date span) = [span]
|
|
||||||
queryDateSpans True (Date2 span) = [span]
|
|
||||||
queryDateSpans _ _ = []
|
|
||||||
|
|
||||||
-- | What date span (or secondary date span) does this query specify ?
|
|
||||||
-- For OR expressions, use the widest possible span. NOT is ignored.
|
|
||||||
queryDateSpan' :: Query -> DateSpan
|
queryDateSpan' :: Query -> DateSpan
|
||||||
queryDateSpan' q = spansUnion $ queryDateSpans' q
|
queryDateSpan' (Or qs) = spansUnion $ map queryDateSpan' qs
|
||||||
|
queryDateSpan' (And qs) = spansIntersect $ map queryDateSpan' qs
|
||||||
-- | Extract all date (or secondary date) spans specified in this query.
|
queryDateSpan' (Date span) = span
|
||||||
-- NOT is ignored.
|
queryDateSpan' (Date2 span) = span
|
||||||
queryDateSpans' :: Query -> [DateSpan]
|
queryDateSpan' _ = nulldatespan
|
||||||
queryDateSpans' (Or qs) = concatMap queryDateSpans' qs
|
|
||||||
queryDateSpans' (And qs) = concatMap queryDateSpans' qs
|
|
||||||
queryDateSpans' (Date span) = [span]
|
|
||||||
queryDateSpans' (Date2 span) = [span]
|
|
||||||
queryDateSpans' _ = []
|
|
||||||
|
|
||||||
-- | What is the earliest of these dates, where Nothing is latest ?
|
-- | What is the earliest of these dates, where Nothing is latest ?
|
||||||
earliestMaybeDate :: [Maybe Day] -> Maybe Day
|
earliestMaybeDate :: [Maybe Day] -> Maybe Day
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user