2018-08-17 14:41:45 +03:00
|
|
|
{-# LANGUAGE CPP #-}
|
2018-03-25 01:51:56 +03:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2018-06-09 05:45:29 +03:00
|
|
|
{-# LANGUAGE RecordWildCards #-}
|
2017-01-20 18:33:24 +03:00
|
|
|
{-|
|
|
|
|
|
2018-07-30 21:38:47 +03:00
|
|
|
A 'PeriodicTransaction' is a rule describing recurring transactions.
|
2017-01-20 18:33:24 +03:00
|
|
|
|
|
|
|
-}
|
2018-07-30 21:38:47 +03:00
|
|
|
module Hledger.Data.PeriodicTransaction (
|
|
|
|
runPeriodicTransaction
|
|
|
|
, checkPeriodicTransactionStartDate
|
|
|
|
)
|
2017-01-20 18:33:24 +03:00
|
|
|
where
|
|
|
|
|
2018-03-25 01:51:56 +03:00
|
|
|
#if !(MIN_VERSION_base(4,11,0))
|
2017-01-20 18:33:24 +03:00
|
|
|
import Data.Monoid ((<>))
|
2018-03-25 01:51:56 +03:00
|
|
|
#endif
|
2017-01-20 18:33:24 +03:00
|
|
|
import qualified Data.Text as T
|
2018-08-17 14:41:45 +03:00
|
|
|
import Text.Printf
|
|
|
|
|
2017-01-20 18:33:24 +03:00
|
|
|
import Hledger.Data.Types
|
|
|
|
import Hledger.Data.Dates
|
|
|
|
import Hledger.Data.Amount
|
2019-07-17 20:38:14 +03:00
|
|
|
import Hledger.Data.Posting (post, commentAddTagNextLine)
|
2017-01-16 17:26:04 +03:00
|
|
|
import Hledger.Data.Transaction
|
|
|
|
import Hledger.Utils.UTF8IOCompat (error')
|
2019-09-12 00:48:07 +03:00
|
|
|
import Hledger.Utils.Debug
|
2017-01-20 18:33:24 +03:00
|
|
|
|
|
|
|
-- $setup
|
|
|
|
-- >>> :set -XOverloadedStrings
|
|
|
|
-- >>> import Hledger.Data.Posting
|
2017-01-16 17:26:04 +03:00
|
|
|
-- >>> import Hledger.Data.Journal
|
2017-01-20 18:33:24 +03:00
|
|
|
|
2018-06-09 05:45:29 +03:00
|
|
|
-- doctest helper, too much hassle to define in the comment
|
|
|
|
-- XXX duplicates some logic in periodictransactionp
|
|
|
|
_ptgen str = do
|
2019-07-15 13:28:52 +03:00
|
|
|
let
|
2018-06-09 05:45:29 +03:00
|
|
|
t = T.pack str
|
|
|
|
(i,s) = parsePeriodExpr' nulldate t
|
|
|
|
case checkPeriodicTransactionStartDate i s t of
|
2020-08-06 02:05:56 +03:00
|
|
|
Just e -> error' e -- PARTIAL:
|
2018-06-09 05:45:29 +03:00
|
|
|
Nothing ->
|
2018-09-05 00:02:04 +03:00
|
|
|
mapM_ (putStr . showTransaction) $
|
2018-06-09 05:45:29 +03:00
|
|
|
runPeriodicTransaction
|
2019-07-15 13:28:52 +03:00
|
|
|
nullperiodictransaction{ ptperiodexpr=t , ptspan=s, ptinterval=i, ptpostings=["a" `post` usd 1] }
|
2018-06-09 05:45:29 +03:00
|
|
|
nulldatespan
|
|
|
|
|
2019-09-12 01:19:21 +03:00
|
|
|
_ptgenspan str span = do
|
|
|
|
let
|
|
|
|
t = T.pack str
|
|
|
|
(i,s) = parsePeriodExpr' nulldate t
|
|
|
|
case checkPeriodicTransactionStartDate i s t of
|
2020-08-06 02:05:56 +03:00
|
|
|
Just e -> error' e -- PARTIAL:
|
2019-09-12 01:19:21 +03:00
|
|
|
Nothing ->
|
|
|
|
mapM_ (putStr . showTransaction) $
|
|
|
|
runPeriodicTransaction
|
|
|
|
nullperiodictransaction{ ptperiodexpr=t , ptspan=s, ptinterval=i, ptpostings=["a" `post` usd 1] }
|
|
|
|
span
|
2018-08-17 14:41:45 +03:00
|
|
|
|
|
|
|
--deriving instance Show PeriodicTransaction
|
|
|
|
-- for better pretty-printing:
|
|
|
|
instance Show PeriodicTransaction where
|
|
|
|
show PeriodicTransaction{..} =
|
|
|
|
printf "PeriodicTransactionPP {%s, %s, %s, %s, %s, %s, %s, %s, %s}"
|
|
|
|
("ptperiodexpr=" ++ show ptperiodexpr)
|
|
|
|
("ptinterval=" ++ show ptinterval)
|
|
|
|
("ptspan=" ++ show (show ptspan))
|
|
|
|
("ptstatus=" ++ show (show ptstatus))
|
|
|
|
("ptcode=" ++ show ptcode)
|
|
|
|
("ptdescription=" ++ show ptdescription)
|
|
|
|
("ptcomment=" ++ show ptcomment)
|
|
|
|
("pttags=" ++ show pttags)
|
|
|
|
("ptpostings=" ++ show ptpostings)
|
|
|
|
|
|
|
|
-- A basic human-readable rendering.
|
|
|
|
--showPeriodicTransaction t = "~ " ++ T.unpack (ptperiodexpr t) ++ "\n" ++ unlines (map show (ptpostings t))
|
|
|
|
|
|
|
|
--nullperiodictransaction is defined in Types.hs
|
|
|
|
|
2017-01-16 17:26:04 +03:00
|
|
|
-- | Generate transactions from 'PeriodicTransaction' within a 'DateSpan'
|
|
|
|
--
|
|
|
|
-- Note that new transactions require 'txnTieKnot' post-processing.
|
2019-07-17 20:38:14 +03:00
|
|
|
-- The new transactions will have three tags added:
|
|
|
|
-- - a recur:PERIODICEXPR tag whose value is the generating periodic expression
|
|
|
|
-- - a generated-transaction: tag
|
|
|
|
-- - a hidden _generated-transaction: tag which does not appear in the comment.
|
2017-01-16 17:26:04 +03:00
|
|
|
--
|
2018-06-09 05:45:29 +03:00
|
|
|
-- >>> _ptgen "monthly from 2017/1 to 2017/4"
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-01-01
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/4
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-01-16 17:26:04 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-02-01
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/4
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-01-16 17:26:04 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-03-01
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/4
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-01-16 17:26:04 +03:00
|
|
|
-- <BLANKLINE>
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
|
|
|
-- >>> _ptgen "monthly from 2017/1 to 2017/5"
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-01-01
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/5
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-02-01
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/5
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-03-01
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/5
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-04-01
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/5
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
|
|
|
-- >>> _ptgen "every 2nd day of month from 2017/02 to 2017/04"
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-01-02
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-02-02
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-03-02
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
|
|
|
-- >>> _ptgen "every 30th day of month from 2017/1 to 2017/5"
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2016-12-30
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-01-30
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-02-28
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-03-30
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-04-30
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
|
|
|
-- >>> _ptgen "every 2nd Thursday of month from 2017/1 to 2017/4"
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2016-12-08
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-01-12
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-02-09
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-03-09
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:44:10 +03:00
|
|
|
-- <BLANKLINE>
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
|
|
|
-- >>> _ptgen "every nov 29th from 2017 to 2019"
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2016-11-29
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every nov 29th from 2017 to 2019
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:43:53 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-11-29
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every nov 29th from 2017 to 2019
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:43:53 +03:00
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2018-11-29
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every nov 29th from 2017 to 2019
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-25 01:43:53 +03:00
|
|
|
-- <BLANKLINE>
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
|
|
|
-- >>> _ptgen "2017/1"
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2017-01-01
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ 2017/1
|
2018-06-09 05:45:29 +03:00
|
|
|
-- a $1.00
|
2017-11-26 06:58:53 +03:00
|
|
|
-- <BLANKLINE>
|
2018-03-29 20:10:25 +03:00
|
|
|
--
|
2018-06-09 05:45:29 +03:00
|
|
|
-- >>> _ptgen ""
|
|
|
|
-- *** Exception: failed to parse...
|
|
|
|
-- ...
|
|
|
|
--
|
|
|
|
-- >>> _ptgen "weekly from 2017"
|
2020-07-21 06:48:55 +03:00
|
|
|
-- *** Exception: Unable to generate transactions according to "weekly from 2017" because 2017-01-01 is not a first day of the Week
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
|
|
|
-- >>> _ptgen "monthly from 2017/5/4"
|
2020-07-21 06:48:55 +03:00
|
|
|
-- *** Exception: Unable to generate transactions according to "monthly from 2017/5/4" because 2017-05-04 is not a first day of the Month
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
|
|
|
-- >>> _ptgen "every quarter from 2017/1/2"
|
2020-07-21 06:48:55 +03:00
|
|
|
-- *** Exception: Unable to generate transactions according to "every quarter from 2017/1/2" because 2017-01-02 is not a first day of the Quarter
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
|
|
|
-- >>> _ptgen "yearly from 2017/1/14"
|
2020-07-21 06:48:55 +03:00
|
|
|
-- *** Exception: Unable to generate transactions according to "yearly from 2017/1/14" because 2017-01-14 is not a first day of the Year
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
|
|
|
-- >>> let reportperiod="daily from 2018/01/03" in let (i,s) = parsePeriodExpr' nulldate reportperiod in runPeriodicTransaction (nullperiodictransaction{ptperiodexpr=reportperiod, ptspan=s, ptinterval=i, ptpostings=["a" `post` usd 1]}) (DateSpan (Just $ parsedate "2018-01-01") (Just $ parsedate "2018-01-03"))
|
2018-03-29 20:10:25 +03:00
|
|
|
-- []
|
2018-06-09 05:45:29 +03:00
|
|
|
--
|
2019-09-12 01:19:21 +03:00
|
|
|
-- >>> _ptgenspan "every 3 months from 2019-05" (mkdatespan "2020-01-01" "2020-02-01")
|
|
|
|
--
|
|
|
|
-- >>> _ptgenspan "every 3 months from 2019-05" (mkdatespan "2020-02-01" "2020-03-01")
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2020-02-01
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 3 months from 2019-05
|
2019-09-12 01:19:21 +03:00
|
|
|
-- a $1.00
|
|
|
|
-- <BLANKLINE>
|
|
|
|
-- >>> _ptgenspan "every 3 days from 2018" (mkdatespan "2018-01-01" "2018-01-05")
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2018-01-01
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 3 days from 2018
|
2019-09-12 01:19:21 +03:00
|
|
|
-- a $1.00
|
|
|
|
-- <BLANKLINE>
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2018-01-04
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 3 days from 2018
|
2019-09-12 01:19:21 +03:00
|
|
|
-- a $1.00
|
|
|
|
-- <BLANKLINE>
|
|
|
|
-- >>> _ptgenspan "every 3 days from 2018" (mkdatespan "2018-01-02" "2018-01-05")
|
2020-02-03 19:03:44 +03:00
|
|
|
-- 2018-01-04
|
2019-10-02 09:30:31 +03:00
|
|
|
-- ; generated-transaction: ~ every 3 days from 2018
|
2019-09-12 01:19:21 +03:00
|
|
|
-- a $1.00
|
|
|
|
-- <BLANKLINE>
|
|
|
|
|
2018-05-07 09:59:30 +03:00
|
|
|
runPeriodicTransaction :: PeriodicTransaction -> DateSpan -> [Transaction]
|
2018-06-09 05:45:29 +03:00
|
|
|
runPeriodicTransaction PeriodicTransaction{..} requestedspan =
|
2019-09-12 00:48:07 +03:00
|
|
|
[ t{tdate=d} | (DateSpan (Just d) _) <- alltxnspans, spanContainsDate requestedspan d ]
|
2018-03-29 20:10:25 +03:00
|
|
|
where
|
2018-06-09 05:45:29 +03:00
|
|
|
t = nulltransaction{
|
|
|
|
tstatus = ptstatus
|
|
|
|
,tcode = ptcode
|
2019-07-15 13:28:52 +03:00
|
|
|
,tdescription = ptdescription
|
2019-07-17 20:38:14 +03:00
|
|
|
,tcomment = ptcomment
|
|
|
|
`commentAddTagNextLine` ("generated-transaction",period)
|
|
|
|
,ttags = ("_generated-transaction",period) :
|
|
|
|
("generated-transaction" ,period) :
|
|
|
|
pttags
|
2018-06-09 05:45:29 +03:00
|
|
|
,tpostings = ptpostings
|
|
|
|
}
|
2019-07-17 20:38:14 +03:00
|
|
|
period = "~ " <> ptperiodexpr
|
2019-09-12 00:48:07 +03:00
|
|
|
-- All spans described by this periodic transaction, where spanStart is event date.
|
|
|
|
-- If transaction does not have start/end date, we set them to start/end of requested span,
|
|
|
|
-- to avoid generating (infinitely) many events.
|
|
|
|
alltxnspans = dbg3 "alltxnspans" $ ptinterval `splitSpan` (spanDefaultsFrom ptspan requestedspan)
|
|
|
|
|
2019-07-15 13:28:52 +03:00
|
|
|
-- | Check that this date span begins at a boundary of this interval,
|
2018-06-09 05:45:29 +03:00
|
|
|
-- or return an explanatory error message including the provided period expression
|
|
|
|
-- (from which the span and interval are derived).
|
2019-07-15 13:28:52 +03:00
|
|
|
checkPeriodicTransactionStartDate :: Interval -> DateSpan -> T.Text -> Maybe String
|
|
|
|
checkPeriodicTransactionStartDate i s periodexpr =
|
2018-06-09 05:45:29 +03:00
|
|
|
case (i, spanStart s) of
|
2020-07-21 06:48:55 +03:00
|
|
|
(Weeks _, Just d) -> checkStart d Week
|
|
|
|
(Months _, Just d) -> checkStart d Month
|
|
|
|
(Quarters _, Just d) -> checkStart d Quarter
|
|
|
|
(Years _, Just d) -> checkStart d Year
|
2019-07-15 13:28:52 +03:00
|
|
|
_ -> Nothing
|
2018-03-29 20:10:25 +03:00
|
|
|
where
|
|
|
|
checkStart d x =
|
2020-08-07 05:18:19 +03:00
|
|
|
let firstDate = fixSmartDate d $ SmartRelative This x
|
2019-07-15 13:28:52 +03:00
|
|
|
in
|
|
|
|
if d == firstDate
|
2018-06-09 05:45:29 +03:00
|
|
|
then Nothing
|
|
|
|
else Just $
|
|
|
|
"Unable to generate transactions according to "++show (T.unpack periodexpr)
|
2020-07-21 06:48:55 +03:00
|
|
|
++" because "++show d++" is not a first day of the "++show x
|
2018-03-29 17:50:48 +03:00
|
|
|
|
2018-07-30 21:29:45 +03:00
|
|
|
---- | What is the interval of this 'PeriodicTransaction's period expression, if it can be parsed ?
|
|
|
|
--periodTransactionInterval :: PeriodicTransaction -> Maybe Interval
|
|
|
|
--periodTransactionInterval pt =
|
|
|
|
-- let
|
|
|
|
-- expr = ptperiodexpr pt
|
|
|
|
-- err = error' $ "Current date cannot be referenced in " ++ show (T.unpack expr)
|
|
|
|
-- in
|
|
|
|
-- case parsePeriodExpr err expr of
|
|
|
|
-- Left _ -> Nothing
|
|
|
|
-- Right (i,_) -> Just i
|