Simon Michael
da8047d286
lib: type signatures
2018-07-24 14:24:45 +01:00
Simon Michael
eb23504906
lib: periodexprp: don't consume trailing whitespace
2018-06-12 16:41:36 -07:00
Alex Chen
c6bfd92dd3
removing "re-parsing" for pull 807
...
For Data/Dates.hs in particular:
- Changed `SimpleTextParser` to `TextParser m` for all parsers
- Changed `string` to the case-insensitive `string'` to match the
behaviour of `T.toLower` found in `parsePeriodExpr`
- export `periodexprp` for "direct" use
2018-06-12 16:41:36 -07:00
Simon Michael
dfcafc2cdf
lib: refactor some journal, period expression parsers
2018-06-12 16:41:36 -07:00
Alex Chen
c5561f25f1
lib: switch parsers to the custom error type
...
Also add an explicit export list to `hledger-lib/Hledger/Utils/Parse.hs`
in order to re-export the custom error type (for convenience).
2018-06-11 13:57:30 -06:00
Simon Michael
0ce9c5728a
switch to base-compat-batteries to fix ghc 7.10 support ( #794 )
...
base-compat-batteries provides the same API across more ghc versions
than base-compat does, at the cost of more dependencies. Eg it exports
Prelude.Compat ((<>)) with ghc 7.10/base 4.8, which we expect.
My belief is that several of our deps already require it so the added
cost is not too great. We should probably go back to base-compat when
possible though, eg when we stop supporting ghc 7.10.
2018-06-04 17:32:42 -07:00
Peter Simons
6db7f800ee
hledger-lib: fix doctest suite after recent package updates
...
The new version of our package set apparently contains both base-compat and
base-compat-batteries in its transitive closure. This breaks the doctest suite,
which just imports everything into scope when the tests are run, thereby making
module names like Prelude.Compat ambiguous.
2018-06-04 21:41:15 +02:00
Alex Chen
12e8d0e282
lib: change some parsers to use takeWhileP
2018-05-22 12:16:46 -07:00
Alex Chen
b245ec7b3d
lib: remove the megaparsec compatability module
2018-05-22 12:16:46 -07:00
Mykola Orliuk
64c7eb78f4
GHC 8.0 compatibility
2018-05-13 14:41:08 -07:00
Stephen Morgan
129f6e6839
Adjust start date of DateSpan for periodic forecasting with Days interval.
2018-05-09 17:19:58 -07:00
Simon Michael
0b5ddcebee
cli: clarify smart dates with more examples; add support for YYYYMM
2018-04-04 17:45:23 +01:00
Simon Michael
d060398484
lib: splitSpan: return no spans for an empty datespan
...
Fixes an issue where a bounded budget could wrongly appear in a
disjoint report period.
2018-03-29 18:10:51 +01:00
Moritz Kiefer
d7b68fbd7d
Use skipMany/skipSome for parsing spacenonewline
...
This avoids allocating the list of space characters only to then
discard it.
2018-03-25 22:59:05 +01:00
Simon Michael
e9624486b6
bs/bse/cf/is: show local abbreviated month names on monthly columns
2018-01-18 11:46:12 -08:00
Mykola Orliuk
48623b4ceb
lib: fix backtracking in periodexpr parser
...
- Simplify doctests for periodexpr.
- Besides consuming leading space consume ending space for periodexpr also.
- Drop implicit option (def, def) behaviour of periodexpr. I.e. disallow
hledger reg -p '' and auto-transaction with heading just '~'.
- Slightly re-factor periodexpr.
- Ensure that reportinginterval doesn't consume trailing space.
Useful if we'll start disallowing periods like "every1stjan2009-".
2017-11-27 06:38:47 -08:00
Dmitry Astapov
597e9c47c9
lib: more periodic transaction tests
...
Some of these demonstrate that runPeriodicTransaction could generate
transactions ouside of requested DateSpan. This happens because
runPeriodicTransaction uses splitSpan internally, and splitSpan always
generates dateSpans that fully cover original DateSpan, extending
beyound left/right boundary if necessary. This is ok if transactions
are generated for budgeting purpose, but during forecasting care should
be taken to check that all generated transactions are happening past
the end of the real journal.
2017-11-26 14:57:41 +00:00
Dmitry Astapov
950891b55b
lib: support "every <weekday>"
...
A shorter spelling for "every <n>th day of week".
2017-11-26 14:57:41 +00:00
Dmitry Astapov
993e3f2b67
lib: support "every 2nd Thursday of month" in period expressions
...
Useful for periodic transactions.
2017-11-26 14:57:41 +00:00
Dmitry Astapov
f1b4618f2d
lib: support "every 11th Nov" in period expressions
...
Useful for periodic transactions
Without it, once-per-year periodic transactions always occur on 1st Jan.
2017-11-26 14:57:37 +00:00
Dmitry Astapov
7acb5d45aa
lib: make month names in period expressions case-insensitive
...
Currently only lower-case account names are supported, both on the
command line, and in the journal (in periodic transactions):
This works:
$ hledger balance -p nov
This does not:
$ hledger balance -p Nov
First transaction will parse, second will not:
```
cat every-month.journal ~/devel/haskell/darcs-get/hledger/examples
~ aug to sep
assets
expenses $1
~ Aug to Sep
assets
expenses $2
```
$../bin/hledger-budget bal -f every-month.journal
hledger-budget: Failed to parse "Aug to Sep": date parse error ()
This commit fixes both cases.
2017-11-26 00:25:08 +00:00
Dmitry Astapov
4049455f26
lib: Fix splitSpan for nthdayof{week,month} - start of DateSpan was not covered
...
Demonstration:
Consider year-test.journal:
```
2015/02/01 first half
expenses $1
assets
2015/07/01 second half
expenses $2
assets
2016/02/01 first half
expenses $4
assets
2016/07/01 second half
expenses $8
assets
2017/02/01 first half
expenses $16
assets
2017/07/01 second half
expenses $32
assets
```
Year balances are good:
```
$ hledger balance -f year-test.journal -p yearly
Balance changes in 2015/01/01-2017/12/31:
|| 2015 2016 2017
==========++==================
assets || $-3 $-12 $-48
expenses || $3 $12 $48
----------++------------------
|| 0 0 0
```
Note how first transaction in 2015 is not included. Note that this is old period expression, so this bug exsits in master:
```$ hledger balance -f year-test.journal -p 'every 2nd day of month'
Balance changes in 2015/07/02-2017/07/01:
|| 2015/07/02-2015/08/01 2015/08/02-2015/09/01 2015/09/02-2015/10/01 2015/10/02-2015/11/01 2015/11/02-2015/12/01 2015/12/02-2016/01/01 2016/01/02-2016/02/01 2016/02/02-2016/03/01 2016/03/02-2016/04/01 2016/04/02-2016/05/01 2016/05/02-2016/06/01 2016/06/02-2016/07/01 2016/07/02-2016/08/01 2016/08/02-2016/09/01 2016/09/02-2016/10/01 2016/10/02-2016/11/01 2016/11/02-2016/12/01 2016/12/02-2017/01/01 2017/01/02-2017/02/01 2017/02/02-2017/03/01 2017/03/02-2017/04/01 2017/04/02-2017/05/01 2017/05/02-2017/06/01 2017/06/02-2017/07/01
==========++========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
assets || 0 0 0 0 0 0 $-4 0 0 0 0 $-8 0 0 0 0 0 0 $-16 0 0 0 0 $-32
expenses || 0 0 0 0 0 0 $4 0 0 0 0 $8 0 0 0 0 0 0 $16 0 0 0 0 $32
----------++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
```
Note how 2015 is absent entirely. This is new expression, but i think that general nature of bug is the same...
```
$ hledger balance -f year-test.journal -p 'every 4th Apr'
Balance changes in 2016/04/04-2018/04/03:
|| 2016/04/04-2017/04/03 2017/04/04-2018/04/03
==========++==============================================
assets || $-24 $-32
expenses || $24 $32
----------++----------------------------------------------
|| 0 0
```
2017-11-25 21:43:13 +00:00
Simon Michael
d7d5f8a064
add support for megaparsec 6 ( fixes #594 )
...
Older megaparsec is still supported.
Also cleans up our custom parser types,
and some text (un)packing is done in different places
(possible performance impact).
2017-07-27 19:20:46 -07:00
Simon Michael
f84324682e
lib: fix a doctest in Hledger.Data.Dates
2016-12-29 11:33:33 -08:00
Simon Michael
9952f93e97
ui: --watch date tracking fixes
...
- move the period only if it's "current" (contains the old "today" date)
- make it work on all screens, not just accounts
2016-12-02 15:36:23 -08:00
Simon Michael
7d81adcefa
lib: use Period for rendering DateSpans
2016-07-29 11:41:42 -07:00
Moritz Kiefer
4141067428
Replace Parsec with Megaparsec (see #289 ) ( #366 )
...
* Replace Parsec with Megaparsec (see #289 )
This builds upon PR #289 by @rasendubi
* Revert renaming of parseWithState to parseWithCtx
* Fix doctests
* Update for Megaparsec 5
* Specialize parser to improve performance
* Pretty print errors
* Swap StateT and ParsecT
This is necessary to get the correct backtracking behavior, i.e. discard
state changes if the parsing fails.
2016-07-29 08:57:10 -07:00
Simon Michael
ad3c5dfb4d
lib: fix ghc 8-related date issues ( #352 )
...
Our null date is now 0000/01/01 instead of 0000/00/00.
2016-05-27 08:06:53 -07:00
Simon Michael
c89c33b36e
lib: textification: parse stream
...
10% more allocation, but 35% lower maximum residency, and slightly quicker.
hledger -f data/100x100x10.journal stats
<<ghc: 39327768 bytes, 77 GCs, 196834/269496 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.010 elapsed), 0.020 MUT (0.092 elapsed), 0.014 GC (0.119 elapsed) :ghc>>
<<ghc: 42842136 bytes, 84 GCs, 194010/270912 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.009 elapsed), 0.016 MUT (0.029 elapsed), 0.012 GC (0.120 elapsed) :ghc>>
hledger -f data/1000x1000x10.journal stats
<<ghc: 314291440 bytes, 612 GCs, 2070776/6628048 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.000 elapsed), 0.128 MUT (0.144 elapsed), 0.059 GC (0.070 elapsed) :ghc>>
<<ghc: 349558872 bytes, 681 GCs, 1397597/4106384 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.004 elapsed), 0.124 MUT (0.133 elapsed), 0.047 GC (0.053 elapsed) :ghc>>
hledger -f data/10000x1000x10.journal stats
<<ghc: 3070026824 bytes, 5973 GCs, 12698030/62951784 avg/max bytes residency (10 samples), 124M in use, 0.000 INIT (0.002 elapsed), 1.268 MUT (1.354 elapsed), 0.514 GC (0.587 elapsed) :ghc>>
<<ghc: 3424013128 bytes, 6658 GCs, 11405501/41071624 avg/max bytes residency (11 samples), 111M in use, 0.000 INIT (0.001 elapsed), 1.343 MUT (1.406 elapsed), 0.511 GC (0.573 elapsed) :ghc>>
hledger -f data/100000x1000x10.journal stats
<<ghc: 30753387392 bytes, 59811 GCs, 117615462/666703600 avg/max bytes residency (14 samples), 1588M in use, 0.000 INIT (0.000 elapsed), 12.068 MUT (12.238 elapsed), 6.015 GC (7.190 elapsed) :ghc>>
<<ghc: 34306530696 bytes, 66727 GCs, 76806196/414629312 avg/max bytes residency (14 samples), 1009M in use, 0.000 INIT (0.010 elapsed), 14.357 MUT (16.370 elapsed), 5.298 GC (6.534 elapsed) :ghc>>
2016-05-24 19:00:57 -07:00
Simon Michael
aac67b3d4d
lib: fix parsedate haddock
2016-05-06 19:02:48 -07:00
Simon Michael
e9c6c1ef5e
lib: convert date hunit tests to doctests
2016-05-06 18:10:49 -07:00
Simon Michael
a52fd599c4
lib: more compact Show instance for datespans
2016-05-06 17:23:24 -07:00
Simon Michael
73e4ccee80
allow year parser to handle arbitrarily large years
2015-07-12 12:32:53 -07:00
Simon Michael
cddaa2724d
rendering a June 30 date span properly ( #272 )
...
30 days hath september, april, JUNE and november
2015-07-02 20:44:39 -07:00
Simon Hengel
964a410b24
hledger-lib: Update for base-compat-0.8.0 (see #245 )
2015-04-23 15:41:59 +08:00
Simon Michael
ab7ed99cc4
fix broken TimeLocale import for ghc 7.8 ( #239 )
2015-03-29 16:30:25 -07:00
Simon Michael
f8a24ccead
fix parseTime warnings with time 1.5+ ( #239 )
2015-03-29 16:12:54 -07:00
Simon Michael
f75849cdd6
fix ghc 7.10 Applicative import warnings ( #239 )
...
Still needed CPP, despite using base-compat.
2015-03-29 16:09:41 -07:00
Simon Michael
e60eb71467
adapt to GHC-7.10's time-1.5 ( #239 )
2015-03-27 15:42:32 -07:00
Simon Michael
3d5b269b3d
fix rendering of week 52 heading in weekly reports
2015-01-18 09:32:14 -08:00
Simon Michael
bd39e5df99
showDateSpan: handle boundary-crossing 1-day spans
...
Eg recognise that 2014/11/30-2014/12/1 can be abbreviated to
2014/11/30d, similarly 2014/12/31-2015/1/1. Doesn't handle feb 29th
correctly, so eg 2000/2/28-2000/3/1 is wrongly abbreviated to
2000/2/28d.
2014-12-03 18:18:05 -08:00
Julien Moutinho
cf28985cf2
lib: move from Text.ParserCombinators.Parsec to Text.Parsec
...
NOTE: required to use liftIO in includedirective
SEE: http://www.vex.net/~trebla/haskell/parsec-generally.xhtml#IO
2014-11-20 10:08:30 +01:00
Simon Michael
23fb4ffd84
export failIfInvalidMonth/Day ( fixes #216 )
2014-10-30 07:58:15 -07:00
gwern
d1618aaca8
strip trailing whitespace from all Haskell files
2014-10-14 18:48:24 -07:00
Simon Michael
aa85e786b9
register: describe datespans briefly, like balance
...
Eg instead of 2014/01/01 - 2014/01/31, show 2014/01, as in a multicolumn
balance report. The data model is not very elegant, but works for now.
2014-08-08 07:34:11 -07:00
Simon Michael
a0010a294f
cli: smart dates must use a consistent separator
...
Along with the preceding commits, this means that date:2014-8/1 is now
parsed as 2014/01/01-2014/08/01 as intended, not 2014/08/01.
2014-08-08 07:21:02 -07:00
Simon Michael
632dee668d
parse period expressions and date: more strictly
...
Period expressions and date: query terms must now be parseable all the
way to their end; we won't ignore unparseable trailing bits.
2014-08-08 07:21:02 -07:00
Simon Michael
1333b2650a
more showDateSpan cleanup
2014-07-26 17:07:36 -07:00
Simon Michael
a7f7c3181f
balance: show compact headings for common intervals
...
In periodic multicolumn balance reports, column headings now show a more
compact description of common periods (years, half-years, quarters,
months, weeks) for better readability and screen space efficiency.
2014-07-26 16:54:18 -07:00
Simon Michael
6af5e6fe06
note potentially useful interval algebra link
2014-04-19 11:45:47 -07:00
Simon Michael
1fca3e7472
orDatesFrom -> spanDefaultsFrom
2014-04-19 08:38:03 -07:00
Simon Michael
020975555e
clarify splitSpan function
2014-04-14 08:31:34 -07:00
Simon Michael
f409f72899
force DateSpans to line-wrap better in debug output
2014-04-03 18:49:57 -07:00
Peter Simons
6319ecd0b7
showDateSpan: remove redundant local definition of showDate
2014-03-22 12:03:00 +01:00
Peter Simons
a56231751f
showDate: use '%0C' to get a two-digit century with time-1.4.0.1 or later
2014-03-22 12:02:22 +01:00
Simon Michael
c53732a4af
balance: new multi-column reports & documentation
...
Two new multi-column balance report modes show ending balance per
period: `--cumulative`, starting from 0, and `--historical`, starting
from the historical starting balance.
The balance command's specification has been clarified and consolidated
in the Balance.hs haddock. Reports.hs has also had haddock updates. The
old AccountsReport type is now BalanceReport, still used by
single-column balance report. The new MultiBalanceReport type is used by
the multi-column reports.
2013-12-07 05:43:31 -08:00
Simon Michael
7e06a6a24c
balance: basic multi-column balance (change) reports
2013-09-26 15:06:48 -07:00
Simon Michael
e75abc4625
parse posting dates, better comment/tag handling, begin using HTF for unit testing
2012-12-06 00:28:23 +00:00
Simon Michael
5b9c5459be
web: make hledger[-lib] compatible with all of yesod's language extensions
...
Useful when building all of hledger-web at once.
2012-11-14 17:25:02 +00:00
Simon Michael
c1e8138609
more date utilities
2012-05-19 02:56:26 +00:00
Simon Michael
88f69e12e2
fix Dates exports for hledger-web
2012-04-16 17:09:27 +00:00
Simon Michael
2f28931d83
fix build warnings in hledger-lib
2012-05-06 20:42:34 +00:00
Simon Michael
68966fe43b
begin cleaning up Dates api, move firstJust
2012-04-16 16:44:41 +00:00
Simon Michael
c22e4e85d0
register: be better at showing empty intervals with --empty and a query pattern
2011-09-23 00:09:39 +00:00
Simon Michael
4228c901e8
change nulldate
2011-06-14 19:10:16 +00:00
Simon Michael
9db32e0f60
haddock fix
2011-07-17 23:14:51 +00:00
Simon Michael
55033b6e79
mkdatespan haddock
2011-07-17 15:54:58 +00:00
Simon Michael
77ca58269a
misc helpers
2011-08-07 15:31:36 +00:00
Simon Michael
c24609f468
refactor fixSmartDate*
2011-08-14 22:39:48 +00:00
Simon Michael
931c64221e
more useful parse error from fixSmartDateStr
2011-08-08 01:34:43 +00:00
Simon Michael
059825a9b2
optionsgeddon.. port to cmdargs and a fully modal cli
2011-08-15 22:50:09 +00:00
Simon Michael
5084280879
imports, api cleanup
2011-05-28 04:11:44 +00:00
Simon Michael
2b1ea5160f
change of mind: "every Nth X of Y" intervals' length shall be Y, not X
2011-01-14 05:01:00 +00:00
Simon Michael
5f1ebc694a
parsing: assume current year when transaction dates have no year and there is no default year
2011-03-11 18:45:57 +00:00
Simon Michael
9bae97821a
really support "every N Xs" reporting intervals, also "every N(st|nd|rd|th) day of (month|week)"
2011-01-14 04:32:08 +00:00
Simon Michael
e96dfc639e
support "every N day/week/month/quarter/years" reporting intervals
2011-01-14 02:35:00 +00:00
Simon Michael
6de45f7d16
support "biweekly" and "bimonthly" reporting intervals
2011-01-14 01:22:53 +00:00
Simon Michael
1c7ad7f421
parsing: more careful validation of eg leap years in transaction dates (only)
2011-04-22 13:55:42 +00:00
Simon Michael
dd9e78a67a
reorganize tests
2010-12-27 20:26:22 +00:00
Simon Michael
4e672f1722
comments
2010-11-19 17:25:39 +00:00
Simon Michael
53ab61ea89
docs: haddock
2010-08-03 17:05:02 +00:00
Simon Michael
0ea8a67c68
type signature
2010-09-05 16:05:38 +00:00
Simon Michael
d29b393ca2
fix a failing test, handle unicode better in errors
2010-09-05 18:18:50 +00:00
Simon Michael
ce7e155934
parsing: fix obscured date parse errors with parsec 3; require split
...
With parsec 3, invalid date errors were not being reported properly.
This should be more robust.
2010-09-03 23:22:58 +00:00
Simon Michael
cf62482102
web: show start and end dates of current filter period in heading, if any
2010-08-01 00:15:21 +00:00
Simon Michael
4f49094088
refactor: date spans, commodities
2010-07-11 18:56:36 +00:00
Simon Michael
331ed6b407
refactor: cleanup
2010-04-14 21:37:03 +00:00
Simon Michael
b19b02962a
parsing: date parsing overhaul, don't exit on bad dates
...
- get rid of undefined parse errors due to guard
- don't call error from date parsers; let add re-prompt on bad dates
- years now must always have at least four digits
- clearer date parse errors
2010-04-14 21:49:34 +00:00
Simon Michael
557746da5e
remove redundant imports revealed by ghc 6.12
2010-05-22 15:33:51 +00:00
Simon Michael
7d4593cee9
move Ledger.* to Hledger.Data.*
2010-05-19 23:08:53 +00:00