mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
lib: spanStartYear, spanEndYear, spanYears DateSpan helpers
This commit is contained in:
parent
a89a4e1b42
commit
4b9a76068f
@ -57,6 +57,9 @@ module Hledger.Data.Dates (
|
||||
isDateSepChar,
|
||||
spanStart,
|
||||
spanEnd,
|
||||
spanStartYear,
|
||||
spanEndYear,
|
||||
spanYears,
|
||||
spansSpan,
|
||||
spanIntersect,
|
||||
spansIntersect,
|
||||
@ -149,6 +152,16 @@ spanStart (DateSpan d _) = d
|
||||
spanEnd :: DateSpan -> Maybe Day
|
||||
spanEnd (DateSpan _ d) = d
|
||||
|
||||
spanStartYear :: DateSpan -> Maybe Year
|
||||
spanStartYear (DateSpan d _) = fmap (first3 . toGregorian) d
|
||||
|
||||
spanEndYear :: DateSpan -> Maybe Year
|
||||
spanEndYear (DateSpan d _) = fmap (first3 . toGregorian) d
|
||||
|
||||
-- | Get the 0-2 years mentioned explicitly in a DateSpan.
|
||||
spanYears :: DateSpan -> [Year]
|
||||
spanYears (DateSpan ma mb) = mapMaybe (fmap (first3 . toGregorian)) [ma,mb]
|
||||
|
||||
-- might be useful later: http://en.wikipedia.org/wiki/Allen%27s_interval_algebra
|
||||
|
||||
-- | Get overall span enclosing multiple sequentially ordered spans.
|
||||
|
Loading…
Reference in New Issue
Block a user