diff --git a/hledger-lib/Hledger/Data/Dates.hs b/hledger-lib/Hledger/Data/Dates.hs index c45a8576e..c068d980f 100644 --- a/hledger-lib/Hledger/Data/Dates.hs +++ b/hledger-lib/Hledger/Data/Dates.hs @@ -40,6 +40,7 @@ module Hledger.Data.Dates ( parsedate, showDate, showDateSpan, + showDateSpanMonthAbbrev, elapsedSeconds, prevday, parsePeriodExpr, @@ -110,6 +111,11 @@ showDate = formatTime defaultTimeLocale "%0C%y/%m/%d" showDateSpan :: DateSpan -> String showDateSpan = showPeriod . dateSpanAsPeriod +-- | Like showDateSpan, but show month spans as just the abbreviated month name +-- in the current locale. +showDateSpanMonthAbbrev :: DateSpan -> String +showDateSpanMonthAbbrev = showPeriodMonthAbbrev . dateSpanAsPeriod + -- | Get the current local date. getCurrentDay :: IO Day getCurrentDay = do diff --git a/hledger-lib/Hledger/Data/Period.hs b/hledger-lib/Hledger/Data/Period.hs index fe6e0dcf5..a9fc1048d 100644 --- a/hledger-lib/Hledger/Data/Period.hs +++ b/hledger-lib/Hledger/Data/Period.hs @@ -144,6 +144,13 @@ showPeriod (PeriodFrom b) = formatTime defaultTimeLocale "%0C%y/%m/%d-" b showPeriod (PeriodTo e) = formatTime defaultTimeLocale "-%0C%y/%m/%d" (addDays (-1) e) -- -INCLUSIVEENDDATE showPeriod PeriodAll = "-" +-- | Like showPeriod, but if it's a month period show just +-- the 3 letter month name abbreviation for the current locale. +showPeriodMonthAbbrev (MonthPeriod _ m) -- Jan + | m >= 0 && m < length monthnames = snd $ monthnames !! (m-1) + where monthnames = months defaultTimeLocale +showPeriodMonthAbbrev p = showPeriod p + periodStart :: Period -> Maybe Day periodStart p = mb where diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index 60d2db4ab..8df762194 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -408,7 +408,7 @@ compoundBalanceReportAsHtml ropts cbr = [tr_ $ th_ [colspanattr, leftattr] $ toHtml title] ++ [thRow $ "" : - map showDateSpan colspans + map showDateSpanMonthAbbrev colspans ++ (if row_total_ ropts then ["Total"] else []) ++ (if average_ ropts then ["Average"] else []) ]