begin cleaning up Dates api, move firstJust
This commit is contained in:
parent
56cf9b21cb
commit
68966fe43b
@ -20,7 +20,33 @@ quarterly, etc.
|
|||||||
|
|
||||||
-- XXX fromGregorian silently clips bad dates, use fromGregorianValid instead ?
|
-- XXX fromGregorian silently clips bad dates, use fromGregorianValid instead ?
|
||||||
|
|
||||||
module Hledger.Data.Dates
|
module Hledger.Data.Dates (
|
||||||
|
-- * Misc date handling utilities
|
||||||
|
getCurrentDay,
|
||||||
|
getCurrentMonth,
|
||||||
|
getCurrentYear,
|
||||||
|
nulldate,
|
||||||
|
spanContainsDate,
|
||||||
|
parsedate,
|
||||||
|
showDate,
|
||||||
|
elapsedSeconds,
|
||||||
|
prevday,
|
||||||
|
parsePeriodExpr,
|
||||||
|
nulldatespan,
|
||||||
|
tests_Hledger_Data_Dates,
|
||||||
|
failIfInvalidYear,
|
||||||
|
datesepchar,
|
||||||
|
datesepchars,
|
||||||
|
spanIntersect,
|
||||||
|
orDatesFrom,
|
||||||
|
smartdate,
|
||||||
|
splitSpan,
|
||||||
|
fixSmartDate,
|
||||||
|
fixSmartDateStr,
|
||||||
|
fixSmartDateStrEither',
|
||||||
|
daysInSpan,
|
||||||
|
maybePeriod,
|
||||||
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
@ -280,10 +306,6 @@ nthdayofweekcontaining n d | d1 >= d = d1
|
|||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
-- parsing
|
-- parsing
|
||||||
|
|
||||||
firstJust ms = case dropWhile (==Nothing) ms of
|
|
||||||
[] -> Nothing
|
|
||||||
(md:_) -> md
|
|
||||||
|
|
||||||
-- | Parse a couple of date-time string formats to a time type.
|
-- | Parse a couple of date-time string formats to a time type.
|
||||||
parsedatetimeM :: String -> Maybe LocalTime
|
parsedatetimeM :: String -> Maybe LocalTime
|
||||||
parsedatetimeM s = firstJust [
|
parsedatetimeM s = firstJust [
|
||||||
|
|||||||
@ -404,3 +404,8 @@ expandPath pos fp = liftM mkAbsolute (expandHome fp)
|
|||||||
expandHome inname | "~/" `isPrefixOf` inname = do homedir <- liftIO getHomeDirectory
|
expandHome inname | "~/" `isPrefixOf` inname = do homedir <- liftIO getHomeDirectory
|
||||||
return $ homedir ++ drop 1 inname
|
return $ homedir ++ drop 1 inname
|
||||||
| otherwise = return inname
|
| otherwise = return inname
|
||||||
|
|
||||||
|
firstJust ms = case dropWhile (==Nothing) ms of
|
||||||
|
[] -> Nothing
|
||||||
|
(md:_) -> md
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user