diff options
author | Ben Sima <ben@bsima.me> | 2020-06-05 14:00:23 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2020-06-05 14:00:35 -0700 |
commit | 6e845a304d9ed416f16338319a276dcfe9e2f539 (patch) | |
tree | a38c93a43c55d13a302cbdf7c2b86930b6f1dd2b | |
parent | 3f93e1002f7de0ef9ab7fb507e31442081419fcd (diff) |
Calculate age automatically
-rwxr-xr-x | hledger-fire.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/hledger-fire.hs b/hledger-fire.hs index b07f012..68ea5a8 100755 --- a/hledger-fire.hs +++ b/hledger-fire.hs @@ -5,18 +5,19 @@ import Data.Decimal (Decimal(..), DecimalRaw(..), roundTo, divide) import Data.Either (fromRight) import qualified Data.List as List import Data.Text (pack) -import Data.Time.Calendar (Day) +import Data.Time.Calendar (Day, toGregorian) import Data.Time.Clock (UTCTime(utctDay), getCurrentTime) import Hledger data Config = Config - { age :: Decimal -- ^ How the heck do i convert btw Decimal and Integer? + { age :: Decimal } main = do - let cfg = Config { age = 27 } j <- getJournal today <- getCurrentTime >>= return . utctDay + let (thisyear, _, _) = toGregorian today + let cfg = Config { age = (fromInteger thisyear) - 1992 } say [ "savings rate:", show $ savingsRate j today ] say [ "target fund:", show $ targetFund j today ] let n = whenFreedom j today |